diff --git a/upub/migrations/src/lib.rs b/upub/migrations/src/lib.rs index 9f66b6ee..40f2ef22 100644 --- a/upub/migrations/src/lib.rs +++ b/upub/migrations/src/lib.rs @@ -12,6 +12,7 @@ mod m20240607_000001_activity_ref_is_optional; mod m20240609_000001_add_instance_field_to_relations; mod m20240623_000001_add_dislikes_table; mod m20240626_000001_add_notifications_table; +mod m20240628_000001_add_followers_following_indexes; pub struct Migrator; @@ -31,6 +32,7 @@ impl MigratorTrait for Migrator { Box::new(m20240609_000001_add_instance_field_to_relations::Migration), Box::new(m20240623_000001_add_dislikes_table::Migration), Box::new(m20240626_000001_add_notifications_table::Migration), + Box::new(m20240628_000001_add_followers_following_indexes::Migration), ] } } diff --git a/upub/migrations/src/m20240628_000001_add_followers_following_indexes.rs b/upub/migrations/src/m20240628_000001_add_followers_following_indexes.rs new file mode 100644 index 00000000..e11b8e36 --- /dev/null +++ b/upub/migrations/src/m20240628_000001_add_followers_following_indexes.rs @@ -0,0 +1,45 @@ +use sea_orm_migration::prelude::*; + +use crate::m20240524_000001_create_actor_activity_object_tables::Actors; + +#[derive(DeriveMigrationName)] +pub struct Migration; + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .create_index( + Index::create() + .name("index-actors-followers") + .table(Actors::Table) + .col(Actors::Followers) + .to_owned() + ) + .await?; + + manager + .create_index( + Index::create() + .name("index-actors-following") + .table(Actors::Table) + .col(Actors::Following) + .to_owned() + ) + .await?; + + Ok(()) + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .drop_index(Index::drop().name("index-actors-followers").table(Actors::Table).to_owned()) + .await?; + + manager + .drop_index(Index::drop().name("index-actors-following").table(Actors::Table).to_owned()) + .await?; + + Ok(()) + } +}