init
This commit is contained in:
@@ -515,10 +515,7 @@ impl MigrationTrait for Migration {
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fk_channel_user_read_state_user")
|
||||
.from(
|
||||
Alias::new("channel_user_read_state"),
|
||||
Alias::new("user_id"),
|
||||
)
|
||||
.from(Alias::new("channel_user_read_state"), Alias::new("user_id"))
|
||||
.to(Alias::new("user"), Alias::new("id"))
|
||||
.on_delete(ForeignKeyAction::Cascade),
|
||||
)
|
||||
@@ -644,6 +641,111 @@ impl MigrationTrait for Migration {
|
||||
// Permissions
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(Alias::new("emoji"))
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(Alias::new("id"))
|
||||
.uuid()
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(Alias::new("server_id")).uuid().null())
|
||||
.col(ColumnDef::new(Alias::new("emoji_type")).string().not_null())
|
||||
.col(ColumnDef::new(Alias::new("unicode_sequence")).text().null())
|
||||
.col(ColumnDef::new(Alias::new("file_path")).text().null())
|
||||
.col(ColumnDef::new(Alias::new("mime_type")).string().null())
|
||||
.col(ColumnDef::new(Alias::new("file_size")).big_integer().null())
|
||||
.col(
|
||||
ColumnDef::new(Alias::new("is_animated"))
|
||||
.boolean()
|
||||
.not_null()
|
||||
.default(false),
|
||||
)
|
||||
.col(ColumnDef::new(Alias::new("sha256")).string().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_emoji_server")
|
||||
.from(Alias::new("emoji"), Alias::new("server_id"))
|
||||
.to(Alias::new("server"), Alias::new("id"))
|
||||
.on_delete(ForeignKeyAction::Cascade),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
manager
|
||||
.create_index(
|
||||
Index::create()
|
||||
.name("idx_emoji_server_id")
|
||||
.table(Alias::new("emoji"))
|
||||
.col(Alias::new("server_id"))
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(Alias::new("emoji_alias"))
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(Alias::new("id"))
|
||||
.uuid()
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(Alias::new("emoji_id")).uuid().not_null())
|
||||
.col(ColumnDef::new(Alias::new("alias")).string().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_emoji_alias_emoji")
|
||||
.from(Alias::new("emoji_alias"), Alias::new("emoji_id"))
|
||||
.to(Alias::new("emoji"), Alias::new("id"))
|
||||
.on_delete(ForeignKeyAction::Cascade),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
manager
|
||||
.create_index(
|
||||
Index::create()
|
||||
.name("uq_emoji_alias_emoji")
|
||||
.table(Alias::new("emoji_alias"))
|
||||
.col(Alias::new("emoji_id"))
|
||||
.col(Alias::new("alias"))
|
||||
.unique()
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
@@ -908,6 +1010,8 @@ impl MigrationTrait for Migration {
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
let tables = [
|
||||
"computed_permission",
|
||||
"emoji_alias",
|
||||
"emoji",
|
||||
"channel_user_read_state",
|
||||
"channel_user_permission",
|
||||
"channel_role_permission",
|
||||
|
||||
Reference in New Issue
Block a user