otter-space-sdk/pkg/database/migrations/003_pools.sql
SoXX c120c583e3
All checks were successful
Gitea Build Check / Build (push) Successful in 2m56s
feat(database): added pools
- added migration
- added model
2024-10-14 12:23:15 +02:00

28 lines
782 B
SQL

-- +migrate Up
CREATE TYPE pool_category AS ENUM ('series', 'collection');
CREATE TABLE "Pool"
(
id CHAR(25) PRIMARY KEY,
name VARCHAR(75),
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP NULL,
category POOL_CATEGORY NOT NULL
);
CREATE TABLE "PoolPost"
(
pool_id CHAR(25) REFERENCES "Pool" (id),
post_id CHAR(25) REFERENCES "Post" (id),
order_position INT NOT NULL DEFAULT 0,
PRIMARY KEY (pool_id, post_id)
);
CREATE TABLE "PoolReference"
(
pool_id CHAR(25) REFERENCES "Pool" (id),
source_id CHAR(25) REFERENCES "Source" (id),
url TEXT NOT NULL,
PRIMARY KEY (pool_id, source_id, url)
);