revert editing session
This commit is contained in:
@@ -15,7 +15,6 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20251011_000003_create_user_identity_table::Migration),
|
||||
Box::new(m20251223_000004_create_upstream_table::Migration),
|
||||
Box::new(m20251223_000005_create_upstream_target_table::Migration),
|
||||
Box::new(m20251230_000006_create_editing_session_table::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,3 @@ pub mod m20251011_000002_create_user_table;
|
||||
pub mod m20251011_000003_create_user_identity_table;
|
||||
pub mod m20251223_000004_create_upstream_table;
|
||||
pub mod m20251223_000005_create_upstream_target_table;
|
||||
pub mod m20251230_000006_create_editing_session_table;
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
use sea_orm_migration::{prelude::*, schema::*};
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
#[forbid(dead_code)]
|
||||
#[derive(DeriveIden)]
|
||||
pub enum EditingSession {
|
||||
Table,
|
||||
Id,
|
||||
Name,
|
||||
CreatedBy,
|
||||
Status,
|
||||
CreatedAt,
|
||||
AppliedAt,
|
||||
AppliedBy,
|
||||
ExpiresAt,
|
||||
}
|
||||
|
||||
#[forbid(dead_code)]
|
||||
#[derive(DeriveIden)]
|
||||
pub enum EditOperation {
|
||||
Table,
|
||||
Id,
|
||||
SessionId,
|
||||
ResourceType,
|
||||
ResourceId,
|
||||
OperationType,
|
||||
Payload,
|
||||
CreatedAt,
|
||||
AppliedAt,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(EditingSession::Table)
|
||||
.if_not_exists()
|
||||
.col(pk_uuid(EditingSession::Id))
|
||||
.col(ColumnDef::new(EditingSession::Name).string().null())
|
||||
.col(ColumnDef::new(EditingSession::CreatedBy).uuid().null())
|
||||
.col(
|
||||
ColumnDef::new(EditingSession::Status)
|
||||
.string()
|
||||
.default("pending")
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(EditingSession::CreatedAt)
|
||||
.timestamp()
|
||||
.default(SimpleExpr::Keyword(Keyword::CurrentTimestamp))
|
||||
.not_null(),
|
||||
)
|
||||
.col(ColumnDef::new(EditingSession::AppliedAt).timestamp().null())
|
||||
.col(ColumnDef::new(EditingSession::AppliedBy).uuid().null())
|
||||
.col(ColumnDef::new(EditingSession::ExpiresAt).timestamp().null())
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(EditOperation::Table)
|
||||
.if_not_exists()
|
||||
.col(pk_uuid(EditOperation::Id))
|
||||
.col(ColumnDef::new(EditOperation::SessionId).uuid().not_null())
|
||||
.col(
|
||||
ColumnDef::new(EditOperation::ResourceType)
|
||||
.string()
|
||||
.not_null(),
|
||||
) // e.g. "upstream", "location"
|
||||
.col(ColumnDef::new(EditOperation::ResourceId).uuid().null()) // null for create
|
||||
.col(
|
||||
ColumnDef::new(EditOperation::OperationType)
|
||||
.string()
|
||||
.not_null(),
|
||||
) // "create"|"update"|"delete"
|
||||
.col(
|
||||
ColumnDef::new(EditOperation::Payload)
|
||||
.json_binary()
|
||||
.not_null(),
|
||||
) // patch or full object
|
||||
.col(
|
||||
ColumnDef::new(EditOperation::CreatedAt)
|
||||
.timestamp()
|
||||
.default(SimpleExpr::Keyword(Keyword::CurrentTimestamp))
|
||||
.not_null(),
|
||||
)
|
||||
.col(ColumnDef::new(EditOperation::AppliedAt).timestamp().null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fk-edit-op-session")
|
||||
.from(EditOperation::Table, EditOperation::SessionId)
|
||||
.to(EditingSession::Table, EditingSession::Id)
|
||||
.on_delete(ForeignKeyAction::Cascade)
|
||||
.on_update(ForeignKeyAction::Cascade),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(EditOperation::Table).to_owned())
|
||||
.await?;
|
||||
manager
|
||||
.drop_table(Table::drop().table(EditingSession::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user