fix: published to addressing index for faster tls

This commit is contained in:
əlemi 2024-05-20 09:13:26 +02:00
parent 2ac0ca8a38
commit c68adc7030
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 84 additions and 0 deletions

View file

@ -0,0 +1,82 @@
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_index(Index::drop().name("addressing-actor-index").to_owned())
.await?;
manager
.create_index(
Index::create()
.name("addressing-actor-index")
.table(Addressing::Table)
.col(Addressing::Actor)
.col(Addressing::Published)
.to_owned()
)
.await?;
manager
.drop_index(Index::drop().name("addressing-server-index").to_owned())
.await?;
manager
.create_index(
Index::create()
.name("addressing-server-index")
.table(Addressing::Table)
.col(Addressing::Server)
.col(Addressing::Published)
.to_owned()
)
.await?;
Ok(())
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_index(Index::drop().name("addressing-actor-index").to_owned())
.await?;
manager
.create_index(
Index::create()
.name("addressing-actor-index")
.table(Addressing::Table)
.col(Addressing::Actor)
.to_owned()
)
.await?;
manager
.drop_index(Index::drop().name("addressing-server-index").to_owned())
.await?;
manager
.create_index(
Index::create()
.name("addressing-server-index")
.table(Addressing::Table)
.col(Addressing::Server)
.to_owned()
)
.await?;
Ok(())
}
}
#[derive(DeriveIden)]
enum Addressing {
Table,
Actor,
Server,
Published,
}

View file

@ -15,6 +15,7 @@ mod m20240424_000001_add_sensitive_field;
mod m20240429_000001_add_relays_table;
mod m20240502_000001_add_object_updated;
mod m20240512_000001_add_url_to_objects;
mod m20240520_000001_add_published_to_addressing_actor_index;
pub struct Migrator;
@ -37,6 +38,7 @@ impl MigratorTrait for Migrator {
Box::new(m20240429_000001_add_relays_table::Migration),
Box::new(m20240502_000001_add_object_updated::Migration),
Box::new(m20240512_000001_add_url_to_objects::Migration),
Box::new(m20240520_000001_add_published_to_addressing_actor_index::Migration),
]
}
}