forked from alemi/upub
chore: likes dont need to record generating activity
This commit is contained in:
parent
06fcf09a5f
commit
b7a8a6004f
4 changed files with 54 additions and 16 deletions
|
@ -7,20 +7,11 @@ 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",
|
||||
|
@ -39,12 +30,6 @@ 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()
|
||||
|
|
|
@ -8,6 +8,7 @@ mod m20240524_000005_create_attachments_tags_mentions;
|
|||
mod m20240529_000001_add_relation_unique_index;
|
||||
mod m20240605_000001_add_jobs_table;
|
||||
mod m20240606_000001_add_audience_to_objects;
|
||||
mod m20240607_000001_activity_ref_is_optional;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
|
@ -23,6 +24,7 @@ impl MigratorTrait for Migrator {
|
|||
Box::new(m20240529_000001_add_relation_unique_index::Migration),
|
||||
Box::new(m20240605_000001_add_jobs_table::Migration),
|
||||
Box::new(m20240606_000001_add_audience_to_objects::Migration),
|
||||
Box::new(m20240607_000001_activity_ref_is_optional::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ pub enum Likes {
|
|||
Internal,
|
||||
Actor,
|
||||
Object,
|
||||
Activity,
|
||||
Activity, // DROPPED
|
||||
Published,
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
use sea_orm_migration::prelude::*;
|
||||
|
||||
use crate::m20240524_000002_create_relations_likes_shares::{Announces, Likes};
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(Likes::Table)
|
||||
.drop_column(Likes::Activity)
|
||||
.to_owned()
|
||||
)
|
||||
.await?;
|
||||
|
||||
manager
|
||||
.create_index(
|
||||
Index::create()
|
||||
.name("index-announces-actor-object")
|
||||
.table(Announces::Table)
|
||||
.col(Announces::Actor)
|
||||
.col(Announces::Object)
|
||||
.to_owned()
|
||||
).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(Likes::Table)
|
||||
.add_column(ColumnDef::new(Likes::Activity).big_integer().not_null())
|
||||
.to_owned()
|
||||
)
|
||||
.await?;
|
||||
|
||||
manager
|
||||
.drop_index(Index::drop().name("index-announces-actor-object").table(Announces::Table).to_owned())
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue