use sea_orm_migration::prelude::*; #[derive(DeriveMigrationName)] pub struct Migration; #[async_trait::async_trait] impl MigrationTrait for Migration { async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { manager .create_table( Table::create() .table(Alias::new("medication_reminder")) .if_not_exists() .col(ColumnDef::new(Alias::new("id")).uuid().not_null().primary_key()) .col(ColumnDef::new(Alias::new("tenant_id")).uuid().not_null()) .col(ColumnDef::new(Alias::new("patient_id")).uuid().not_null()) .col(ColumnDef::new(Alias::new("medication_name")).string().not_null()) .col(ColumnDef::new(Alias::new("dosage")).string()) .col(ColumnDef::new(Alias::new("frequency")).string()) .col(ColumnDef::new(Alias::new("reminder_times")).json().not_null()) .col(ColumnDef::new(Alias::new("start_date")).date()) .col(ColumnDef::new(Alias::new("end_date")).date()) .col(ColumnDef::new(Alias::new("is_active")).boolean().not_null().default(true)) .col(ColumnDef::new(Alias::new("notes")).string()) .col(ColumnDef::new(Alias::new("created_at")).timestamp_with_time_zone().not_null()) .col(ColumnDef::new(Alias::new("updated_at")).timestamp_with_time_zone().not_null()) .col(ColumnDef::new(Alias::new("created_by")).uuid()) .col(ColumnDef::new(Alias::new("updated_by")).uuid()) .col(ColumnDef::new(Alias::new("deleted_at")).timestamp_with_time_zone()) .col(ColumnDef::new(Alias::new("version")).integer().not_null().default(1)) .to_owned(), ) .await?; manager .create_index( Index::create() .name("idx_medication_reminder_patient") .table(Alias::new("medication_reminder")) .col(Alias::new("tenant_id")) .col(Alias::new("patient_id")) .col(Alias::new("deleted_at")) .to_owned(), ) .await } async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { manager .drop_table(Table::drop().table(Alias::new("medication_reminder")).to_owned()) .await } }