diff --git a/server/migrations/20241217021645_create-search-table.down.sql b/server/migrations/20241217021645_create-search-table.down.sql new file mode 100644 index 0000000..0870a92 --- /dev/null +++ b/server/migrations/20241217021645_create-search-table.down.sql @@ -0,0 +1 @@ +DROP INDEX IF EXISTS post_summary_idx; diff --git a/server/migrations/20241217021645_create-search-table.up.sql b/server/migrations/20241217021645_create-search-table.up.sql new file mode 100644 index 0000000..27a85a1 --- /dev/null +++ b/server/migrations/20241217021645_create-search-table.up.sql @@ -0,0 +1 @@ +CREATE INDEX post_summary_idx ON post USING GIN (to_tsvector('english', summary)); diff --git a/server/src/bin/server.rs b/server/src/bin/server.rs index 76f03d2..eb7f330 100644 --- a/server/src/bin/server.rs +++ b/server/src/bin/server.rs @@ -215,6 +215,7 @@ async fn main() -> Result<(), Box> { std::fs::create_dir_all(&config.slurp_cache_path)?; } let pool = PgPool::connect(&config.newsreader_database_url).await?; + sqlx::migrate!("./migrations").run(&pool).await?; let tantivy_conn = TantivyConnection::new(&config.newsreader_tantivy_db_path)?; let schema = Schema::build(QueryRoot, Mutation, EmptySubscription)