remove author column from articles

This commit is contained in:
2025-01-07 11:59:10 +01:00
parent b16ebb9572
commit ce10e1e62b
4 changed files with 74 additions and 57 deletions

View File

@@ -0,0 +1,36 @@
-- +goose Up
-- +goose StatementBegin
BEGIN;
DROP INDEX IF EXISTS articles_fts_idx;
ALTER TABLE articles DROP COLUMN IF EXISTS fts_vector;
ALTER TABLE articles DROP COLUMN IF EXISTS author;
ALTER TABLE articles
ADD COLUMN fts_vector tsvector GENERATED ALWAYS AS (
to_tsvector('german', coalesce(title, '') || ' ' || coalesce(content, ''))
) STORED;
CREATE INDEX articles_fts_idx ON articles USING gin(fts_vector);
COMMIT;
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
BEGIN;
ALTER TABLE articles ADD COLUMN author VARCHAR(255) DEFAULT '';
DROP INDEX IF EXISTS articles_fts_idx;
ALTER TABLE articles DROP COLUMN IF EXISTS fts_vector;
ALTER TABLE articles
ADD COLUMN fts_vector tsvector GENERATED ALWAYS AS (
to_tsvector('german', coalesce(title, '') || ' ' || coalesce(content, '') || ' ' || coalesce(author, ''))
) STORED;
CREATE INDEX articles_fts_idx ON articles USING gin(fts_vector);
COMMIT;
-- +goose StatementEnd