init
This commit is contained in:
@@ -243,12 +243,6 @@ impl MigrationTrait for Migration {
|
||||
)
|
||||
.col(ColumnDef::new(Alias::new("server_id")).uuid().not_null())
|
||||
.col(ColumnDef::new(Alias::new("name")).string().not_null())
|
||||
.col(
|
||||
ColumnDef::new(Alias::new("position"))
|
||||
.integer()
|
||||
.not_null()
|
||||
.default(0),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Alias::new("created_at"))
|
||||
.timestamp_with_time_zone()
|
||||
@@ -285,12 +279,6 @@ impl MigrationTrait for Migration {
|
||||
)
|
||||
.col(ColumnDef::new(Alias::new("server_id")).uuid().null())
|
||||
.col(ColumnDef::new(Alias::new("category_id")).uuid().null())
|
||||
.col(
|
||||
ColumnDef::new(Alias::new("position"))
|
||||
.integer()
|
||||
.not_null()
|
||||
.default(0),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Alias::new("channel_type"))
|
||||
.integer()
|
||||
@@ -327,6 +315,86 @@ impl MigrationTrait for Migration {
|
||||
)
|
||||
.await?;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Ordre des catégories et des canaux (Polymorphique)
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(Alias::new("server_item_order"))
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(Alias::new("id"))
|
||||
.uuid()
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(Alias::new("server_id")).uuid().not_null())
|
||||
.col(ColumnDef::new(Alias::new("resource_id")).uuid().not_null())
|
||||
.col(
|
||||
ColumnDef::new(Alias::new("resource_type"))
|
||||
.integer()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Alias::new("parent_category_id"))
|
||||
.uuid()
|
||||
.null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Alias::new("order_key"))
|
||||
.big_integer()
|
||||
.not_null(),
|
||||
)
|
||||
.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()),
|
||||
)
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fk_server_item_order_server")
|
||||
.from(Alias::new("server_item_order"), Alias::new("server_id"))
|
||||
.to(Alias::new("server"), Alias::new("id"))
|
||||
.on_delete(ForeignKeyAction::Cascade),
|
||||
)
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fk_server_item_order_parent_category")
|
||||
.from(
|
||||
Alias::new("server_item_order"),
|
||||
Alias::new("parent_category_id"),
|
||||
)
|
||||
.to(Alias::new("category"), Alias::new("id"))
|
||||
.on_delete(ForeignKeyAction::Cascade),
|
||||
)
|
||||
.index(
|
||||
Index::create()
|
||||
.name("uq_server_item_order_resource")
|
||||
.col(Alias::new("server_id"))
|
||||
.col(Alias::new("resource_type"))
|
||||
.col(Alias::new("resource_id"))
|
||||
.unique(),
|
||||
)
|
||||
.index(
|
||||
Index::create()
|
||||
.name("idx_server_item_order_scope")
|
||||
.col(Alias::new("server_id"))
|
||||
.col(Alias::new("parent_category_id"))
|
||||
.col(Alias::new("order_key")),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Membres des canaux
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -716,7 +784,6 @@ impl MigrationTrait for Migration {
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
// Les tables dépendantes doivent être supprimées avant leurs parents.
|
||||
let tables = [
|
||||
"computed_permission",
|
||||
"channel_user_permission",
|
||||
@@ -726,6 +793,7 @@ impl MigrationTrait for Migration {
|
||||
"attachment",
|
||||
"message",
|
||||
"channel_user",
|
||||
"server_item_order",
|
||||
"channel",
|
||||
"category",
|
||||
"role_user",
|
||||
|
||||
Reference in New Issue
Block a user