mirror of
https://github.com/versia-pub/activitypub.git
synced 2025-12-06 06:38:20 +01:00
[fix] make third mig sqlite compatible
This commit is contained in:
parent
99304aa53a
commit
ff728ef6f3
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -4,4 +4,5 @@
|
||||||
/result
|
/result
|
||||||
/result-lib
|
/result-lib
|
||||||
.direnv
|
.direnv
|
||||||
migration/target
|
migration/target
|
||||||
|
db.sqlite
|
||||||
|
|
@ -8,45 +8,62 @@ pub struct Migration;
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl MigrationTrait for Migration {
|
impl MigrationTrait for Migration {
|
||||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
|
||||||
|
manager.drop_table(Table::drop().table(Post::Table).to_owned()).await?;
|
||||||
|
|
||||||
manager
|
manager
|
||||||
.alter_table(
|
.create_table(
|
||||||
Table::alter()
|
Table::create()
|
||||||
.table(Post::Table)
|
.table(Post::Table)
|
||||||
.add_foreign_key(
|
.if_not_exists()
|
||||||
|
.col(ColumnDef::new(Post::Id).string().not_null().primary_key())
|
||||||
|
.col(ColumnDef::new(Post::Title).string())
|
||||||
|
.col(ColumnDef::new(Post::Content).string().not_null())
|
||||||
|
.col(ColumnDef::new(Post::Local).boolean().not_null())
|
||||||
|
.col(ColumnDef::new(Post::CreatedAt).timestamp().not_null())
|
||||||
|
.col(ColumnDef::new(Post::UpdatedAt).timestamp())
|
||||||
|
.col(ColumnDef::new(Post::ReblogId).string())
|
||||||
|
.col(ColumnDef::new(Post::ContentType).string().not_null())
|
||||||
|
.col(ColumnDef::new(Post::Visibility).string().not_null())
|
||||||
|
.col(ColumnDef::new(Post::ReplyId).string())
|
||||||
|
.col(ColumnDef::new(Post::QuotingId).string())
|
||||||
|
.col(ColumnDef::new(Post::Sensitive).boolean().not_null())
|
||||||
|
.col(ColumnDef::new(Post::SpoilerText).string())
|
||||||
|
.col(ColumnDef::new(Post::Creator).string().not_null())
|
||||||
|
.col(ColumnDef::new(Post::Url).string().not_null())
|
||||||
|
.foreign_key(
|
||||||
ForeignKey::create()
|
ForeignKey::create()
|
||||||
.name("fk_post_creator_user_id")
|
.name("fk_post_creator_user_id")
|
||||||
.from(Post::Table, Post::Creator)
|
.from(Post::Table, Post::Creator)
|
||||||
.to(User::Table, User::Id)
|
.to(User::Table, User::Id)
|
||||||
.on_delete(ForeignKeyAction::Cascade)
|
.on_delete(ForeignKeyAction::Cascade),
|
||||||
.get_foreign_key(),
|
|
||||||
)
|
)
|
||||||
.add_foreign_key(
|
.foreign_key(
|
||||||
ForeignKey::create()
|
ForeignKey::create()
|
||||||
.name("fk_post_reblog_id")
|
.name("fk_post_reblog_id")
|
||||||
.from(Post::Table, Post::ReblogId)
|
.from(Post::Table, Post::ReblogId)
|
||||||
.to(Post::Table, Post::Id)
|
.to(Post::Table, Post::Id)
|
||||||
.on_delete(ForeignKeyAction::Cascade)
|
.on_delete(ForeignKeyAction::Cascade),
|
||||||
.get_foreign_key(),
|
|
||||||
)
|
)
|
||||||
.add_foreign_key(
|
.foreign_key(
|
||||||
ForeignKey::create()
|
ForeignKey::create()
|
||||||
.name("fk_post_reply_id")
|
.name("fk_post_reply_id")
|
||||||
.from(Post::Table, Post::ReplyId)
|
.from(Post::Table, Post::ReplyId)
|
||||||
.to(Post::Table, Post::Id)
|
.to(Post::Table, Post::Id)
|
||||||
.on_delete(ForeignKeyAction::Cascade)
|
.on_delete(ForeignKeyAction::Cascade),
|
||||||
.get_foreign_key(),
|
|
||||||
)
|
)
|
||||||
.add_foreign_key(
|
.foreign_key(
|
||||||
ForeignKey::create()
|
ForeignKey::create()
|
||||||
.name("fk_post_quoting_id")
|
.name("fk_post_quoting_id")
|
||||||
.from(Post::Table, Post::QuotingId)
|
.from(Post::Table, Post::QuotingId)
|
||||||
.to(Post::Table, Post::Id)
|
.to(Post::Table, Post::Id)
|
||||||
.on_delete(ForeignKeyAction::Cascade)
|
.on_delete(ForeignKeyAction::Cascade),
|
||||||
.get_foreign_key(),
|
|
||||||
)
|
)
|
||||||
.to_owned(),
|
.to_owned(),
|
||||||
)
|
)
|
||||||
.await
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue