feat: full-text index on content

This commit is contained in:
əlemi 2024-08-11 14:45:03 +02:00
parent 2d92f9c355
commit 7a9a6fc245
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 32 additions and 0 deletions

View file

@ -19,6 +19,7 @@ mod m20240703_000002_add_image_to_objects;
mod m20240706_000001_add_error_to_jobs; mod m20240706_000001_add_error_to_jobs;
mod m20240715_000001_add_quote_uri_to_objects; mod m20240715_000001_add_quote_uri_to_objects;
mod m20240715_000002_add_actors_fields_and_aliases; mod m20240715_000002_add_actors_fields_and_aliases;
mod m20240811_000001_add_full_text_index;
pub struct Migrator; pub struct Migrator;
@ -45,6 +46,7 @@ impl MigratorTrait for Migrator {
Box::new(m20240706_000001_add_error_to_jobs::Migration), Box::new(m20240706_000001_add_error_to_jobs::Migration),
Box::new(m20240715_000001_add_quote_uri_to_objects::Migration), Box::new(m20240715_000001_add_quote_uri_to_objects::Migration),
Box::new(m20240715_000002_add_actors_fields_and_aliases::Migration), Box::new(m20240715_000002_add_actors_fields_and_aliases::Migration),
Box::new(m20240811_000001_add_full_text_index::Migration),
] ]
} }
} }

View file

@ -0,0 +1,30 @@
use sea_orm_migration::prelude::*;
use crate::m20240524_000001_create_actor_activity_object_tables::Objects;
#[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-objects-content")
.table(Objects::Table)
.col(Objects::Audience)
.full_text()
.to_owned()
)
.await?;
Ok(())
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_index(Index::drop().name("index-objects-content").table(Objects::Table).to_owned())
.await?;
Ok(())
}
}