feat!: also store like activity

oops redo all your migrations (: this will be necessary to do undos in
the frontend
This commit is contained in:
əlemi 2024-05-28 01:25:47 +02:00
parent 7cc9d820f6
commit c97b35a6a7
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 25 additions and 0 deletions

View file

@ -19,6 +19,7 @@ pub enum Likes {
Internal,
Actor,
Object,
Activity,
Published,
}
@ -130,6 +131,15 @@ impl MigrationTrait for Migration {
.on_update(ForeignKeyAction::Cascade)
.on_delete(ForeignKeyAction::Cascade)
)
.col(ColumnDef::new(Likes::Activity).big_integer().not_null())
.foreign_key(
ForeignKey::create()
.name("fkey-likes-activity")
.from(Likes::Table, Likes::Activity)
.to(Activities::Table, Activities::Internal)
.on_update(ForeignKeyAction::Cascade)
.on_delete(ForeignKeyAction::Cascade)
)
.col(ColumnDef::new(Likes::Published).date_time().not_null().default(Expr::current_timestamp()))
.to_owned()
)

View file

@ -7,11 +7,20 @@ pub struct Model {
pub internal: i64,
pub actor: i64,
pub object: i64,
pub activity: i64,
pub published: ChronoDateTimeUtc,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::activity::Entity",
from = "Column::Activity",
to = "super::activity::Column::Internal",
on_update = "Cascade",
on_delete = "Cascade"
)]
Activities,
#[sea_orm(
belongs_to = "super::actor::Entity",
from = "Column::Actor",
@ -30,6 +39,12 @@ pub enum Relation {
Objects,
}
impl Related<super::activity::Entity> for Entity {
fn to() -> RelationDef {
Relation::Activities.def()
}
}
impl Related<super::actor::Entity> for Entity {
fn to() -> RelationDef {
Relation::Actors.def()