change db from sqlite3 to postgresql
This commit is contained in:
17
assets/migrations/postgresql/20250102152758_article.sql
Normal file
17
assets/migrations/postgresql/20250102152758_article.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE articles (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
sourceUrl VARCHAR(255) NOT NULL UNIQUE,
|
||||
author VARCHAR(255) NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
publishDate TIMESTAMP NOT NULL,
|
||||
fetchDate TIMESTAMP NOT NULL
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS articles;
|
||||
-- +goose StatementEnd
|
||||
15
assets/migrations/postgresql/20250102232127_article_fts.sql
Normal file
15
assets/migrations/postgresql/20250102232127_article_fts.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
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);
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP INDEX IF EXISTS articles_fts_idx;
|
||||
ALTER TABLE articles DROP COLUMN IF EXISTS fts_vector;
|
||||
-- +goose StatementEnd
|
||||
@@ -0,0 +1,13 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE responses (
|
||||
url VARCHAR(255) NOT NULL UNIQUE PRIMARY KEY,
|
||||
content BYTEA NOT NULL,
|
||||
fetchDate TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS responses;
|
||||
-- +goose StatementEnd
|
||||
@@ -0,0 +1,9 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE responses ADD COLUMN processed BOOLEAN DEFAULT false;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE responses DROP COLUMN IF EXISTS processed;
|
||||
-- +goose StatementEnd
|
||||
Reference in New Issue
Block a user