forked from alemi/upub
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:
parent
7cc9d820f6
commit
c97b35a6a7
2 changed files with 25 additions and 0 deletions
|
@ -19,6 +19,7 @@ pub enum Likes {
|
||||||
Internal,
|
Internal,
|
||||||
Actor,
|
Actor,
|
||||||
Object,
|
Object,
|
||||||
|
Activity,
|
||||||
Published,
|
Published,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +131,15 @@ impl MigrationTrait for Migration {
|
||||||
.on_update(ForeignKeyAction::Cascade)
|
.on_update(ForeignKeyAction::Cascade)
|
||||||
.on_delete(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()))
|
.col(ColumnDef::new(Likes::Published).date_time().not_null().default(Expr::current_timestamp()))
|
||||||
.to_owned()
|
.to_owned()
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,11 +7,20 @@ pub struct Model {
|
||||||
pub internal: i64,
|
pub internal: i64,
|
||||||
pub actor: i64,
|
pub actor: i64,
|
||||||
pub object: i64,
|
pub object: i64,
|
||||||
|
pub activity: i64,
|
||||||
pub published: ChronoDateTimeUtc,
|
pub published: ChronoDateTimeUtc,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
pub enum Relation {
|
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(
|
#[sea_orm(
|
||||||
belongs_to = "super::actor::Entity",
|
belongs_to = "super::actor::Entity",
|
||||||
from = "Column::Actor",
|
from = "Column::Actor",
|
||||||
|
@ -30,6 +39,12 @@ pub enum Relation {
|
||||||
Objects,
|
Objects,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Related<super::activity::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::Activities.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Related<super::actor::Entity> for Entity {
|
impl Related<super::actor::Entity> for Entity {
|
||||||
fn to() -> RelationDef {
|
fn to() -> RelationDef {
|
||||||
Relation::Actors.def()
|
Relation::Actors.def()
|
||||||
|
|
Loading…
Reference in a new issue