fix: objects before activities

This commit is contained in:
əlemi 2024-05-24 03:55:43 +02:00
parent ab0e7007c5
commit e3dc3f9ae7
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -177,63 +177,6 @@ impl MigrationTrait for Migration {
manager
.create_table(
Table::create()
.table(Activities::Table)
.comment("all activities this instance ever received or generated")
.col(
ColumnDef::new(Activities::Id)
.integer()
.not_null()
.primary_key()
.auto_increment()
)
.col(ColumnDef::new(Activities::ApId).string().not_null().unique_key())
.col(ColumnDef::new(Activities::ActivityType).string().not_null())
.col(ColumnDef::new(Activities::Actor).integer().not_null())
.foreign_key(
ForeignKey::create()
.name("fkey-activities-actors")
.from(Activities::Table, Activities::Actor)
.to(Actors::Table, Actors::Id)
.on_update(ForeignKeyAction::Cascade)
)
.col(ColumnDef::new(Activities::Object).integer().null())
.foreign_key(
ForeignKey::create()
.name("fkey-activities-objects")
.from(Activities::Table, Activities::Object)
.to(Objects::Table, Objects::Id)
.on_update(ForeignKeyAction::Cascade)
)
.col(ColumnDef::new(Activities::Target).string().null())
.col(ColumnDef::new(Activities::To).json().null())
.col(ColumnDef::new(Activities::Bto).json().null())
.col(ColumnDef::new(Activities::Cc).json().null())
.col(ColumnDef::new(Activities::Bcc).json().null())
.col(ColumnDef::new(Activities::Published).date_time().not_null().default(Expr::current_timestamp()))
.to_owned()
).await?;
manager
.create_index(Index::create().unique().name("index-activities-ap-id").table(Activities::Table).col(Activities::ApId).to_owned())
.await?;
manager
.create_index(Index::create().name("index-activities-actor").table(Activities::Table).col(Activities::Actor).to_owned())
.await?;
manager
.create_index(Index::create().name("activities-object-index").table(Activities::Table).col(Activities::Object).to_owned())
.await?;
manager
.create_index(Index::create().name("index-activities-published-descending").table(Activities::Table).col((Activities::Published, IndexOrder::Desc)).to_owned())
.await?;
manager manager
.create_table( .create_table(
Table::create() Table::create()
@ -295,6 +238,63 @@ impl MigrationTrait for Migration {
.create_index(Index::create().name("index-objects-context").table(Objects::Table).col(Objects::Context).to_owned()) .create_index(Index::create().name("index-objects-context").table(Objects::Table).col(Objects::Context).to_owned())
.await?; .await?;
manager
.create_table(
Table::create()
.table(Activities::Table)
.comment("all activities this instance ever received or generated")
.col(
ColumnDef::new(Activities::Id)
.integer()
.not_null()
.primary_key()
.auto_increment()
)
.col(ColumnDef::new(Activities::ApId).string().not_null().unique_key())
.col(ColumnDef::new(Activities::ActivityType).string().not_null())
.col(ColumnDef::new(Activities::Actor).integer().not_null())
.foreign_key(
ForeignKey::create()
.name("fkey-activities-actors")
.from(Activities::Table, Activities::Actor)
.to(Actors::Table, Actors::Id)
.on_update(ForeignKeyAction::Cascade)
)
.col(ColumnDef::new(Activities::Object).integer().null())
.foreign_key(
ForeignKey::create()
.name("fkey-activities-objects")
.from(Activities::Table, Activities::Object)
.to(Objects::Table, Objects::Id)
.on_update(ForeignKeyAction::Cascade)
)
.col(ColumnDef::new(Activities::Target).string().null())
.col(ColumnDef::new(Activities::To).json().null())
.col(ColumnDef::new(Activities::Bto).json().null())
.col(ColumnDef::new(Activities::Cc).json().null())
.col(ColumnDef::new(Activities::Bcc).json().null())
.col(ColumnDef::new(Activities::Published).date_time().not_null().default(Expr::current_timestamp()))
.to_owned()
).await?;
manager
.create_index(Index::create().unique().name("index-activities-ap-id").table(Activities::Table).col(Activities::ApId).to_owned())
.await?;
manager
.create_index(Index::create().name("index-activities-actor").table(Activities::Table).col(Activities::Actor).to_owned())
.await?;
manager
.create_index(Index::create().name("activities-object-index").table(Activities::Table).col(Activities::Object).to_owned())
.await?;
manager
.create_index(Index::create().name("index-activities-published-descending").table(Activities::Table).col((Activities::Published, IndexOrder::Desc)).to_owned())
.await?;
Ok(()) Ok(())
} }