init
This commit is contained in:
@@ -712,6 +712,81 @@ impl MigrationTrait for Migration {
|
||||
|
||||
seed_unicode_emojis(manager).await?;
|
||||
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(Alias::new("message_reaction"))
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(Alias::new("id"))
|
||||
.uuid()
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(Alias::new("message_id")).uuid().not_null())
|
||||
.col(ColumnDef::new(Alias::new("user_id")).uuid().not_null())
|
||||
.col(ColumnDef::new(Alias::new("emoji_id")).uuid().not_null())
|
||||
.col(
|
||||
ColumnDef::new(Alias::new("skin_tone"))
|
||||
.integer()
|
||||
.not_null()
|
||||
.default(0),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Alias::new("created_at"))
|
||||
.timestamp_with_time_zone()
|
||||
.not_null()
|
||||
.default(Expr::current_timestamp()),
|
||||
)
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fk_message_reaction_message")
|
||||
.from(Alias::new("message_reaction"), Alias::new("message_id"))
|
||||
.to(Alias::new("message"), Alias::new("id"))
|
||||
.on_delete(ForeignKeyAction::Cascade),
|
||||
)
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fk_message_reaction_user")
|
||||
.from(Alias::new("message_reaction"), Alias::new("user_id"))
|
||||
.to(Alias::new("user"), Alias::new("id"))
|
||||
.on_delete(ForeignKeyAction::Cascade),
|
||||
)
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fk_message_reaction_emoji")
|
||||
.from(Alias::new("message_reaction"), 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_message_reaction")
|
||||
.table(Alias::new("message_reaction"))
|
||||
.col(Alias::new("message_id"))
|
||||
.col(Alias::new("user_id"))
|
||||
.col(Alias::new("emoji_id"))
|
||||
.col(Alias::new("skin_tone"))
|
||||
.unique()
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
manager
|
||||
.create_index(
|
||||
Index::create()
|
||||
.name("idx_message_reaction_message_id")
|
||||
.table(Alias::new("message_reaction"))
|
||||
.col(Alias::new("message_id"))
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
@@ -976,6 +1051,7 @@ impl MigrationTrait for Migration {
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
let tables = [
|
||||
"computed_permission",
|
||||
"message_reaction",
|
||||
"emoji",
|
||||
"channel_user_read_state",
|
||||
"channel_user_permission",
|
||||
|
||||
Reference in New Issue
Block a user