From 7a9a6fc245c857763d58aa2c564b2918bbcfbc60 Mon Sep 17 00:00:00 2001 From: alemi Date: Sun, 11 Aug 2024 14:45:03 +0200 Subject: [PATCH] feat: full-text index on content --- upub/migrations/src/lib.rs | 2 ++ .../m20240811_000001_add_full_text_index.rs | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 upub/migrations/src/m20240811_000001_add_full_text_index.rs diff --git a/upub/migrations/src/lib.rs b/upub/migrations/src/lib.rs index 9f21475..aa1cc06 100644 --- a/upub/migrations/src/lib.rs +++ b/upub/migrations/src/lib.rs @@ -19,6 +19,7 @@ mod m20240703_000002_add_image_to_objects; mod m20240706_000001_add_error_to_jobs; mod m20240715_000001_add_quote_uri_to_objects; mod m20240715_000002_add_actors_fields_and_aliases; +mod m20240811_000001_add_full_text_index; pub struct Migrator; @@ -45,6 +46,7 @@ impl MigratorTrait for Migrator { Box::new(m20240706_000001_add_error_to_jobs::Migration), Box::new(m20240715_000001_add_quote_uri_to_objects::Migration), Box::new(m20240715_000002_add_actors_fields_and_aliases::Migration), + Box::new(m20240811_000001_add_full_text_index::Migration), ] } } diff --git a/upub/migrations/src/m20240811_000001_add_full_text_index.rs b/upub/migrations/src/m20240811_000001_add_full_text_index.rs new file mode 100644 index 0000000..30a1ec4 --- /dev/null +++ b/upub/migrations/src/m20240811_000001_add_full_text_index.rs @@ -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(()) + } +}