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("plugin_user_views")) .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("user_id")).uuid().not_null()) .col(ColumnDef::new(Alias::new("plugin_id")).string().not_null()) .col( ColumnDef::new(Alias::new("entity_name")) .string() .not_null(), ) .col(ColumnDef::new(Alias::new("view_name")).string().not_null()) .col(ColumnDef::new(Alias::new("view_config")).json().not_null()) .col( ColumnDef::new(Alias::new("is_default")) .boolean() .not_null() .default(false), ) .col( ColumnDef::new(Alias::new("created_at")) .timestamp_with_time_zone() .not_null() .default(Expr::current_timestamp()), ) .col( ColumnDef::new(Alias::new("updated_at")) .timestamp_with_time_zone() .not_null() .default(Expr::current_timestamp()), ) .to_owned(), ) .await } async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { manager .drop_table( Table::drop() .table(Alias::new("plugin_user_views")) .to_owned(), ) .await } }