feat: add indexes on followers/following fields

will use them for proper address expansion soon™️
This commit is contained in:
əlemi 2024-06-28 05:10:57 +02:00
parent 8b5e6d805d
commit 1ee7eb1498
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 47 additions and 0 deletions

View file

@ -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),
]
}
}

View file

@ -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(())
}
}