feat(database): added additional columns

added more columns

BREAKING-CHANGE: breaks database compatibility to older SDK versions
This commit is contained in:
SoXX 2024-08-09 21:37:27 +02:00
parent c2ab455d3e
commit e62280a416

View File

@ -18,7 +18,7 @@ CREATE TYPE TagType AS ENUM (
CREATE TABLE "Post" CREATE TABLE "Post"
( (
id CHAR(25) PRIMARY KEY, id CHAR(25) PRIMARY KEY,
rating Rating, rating Rating,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
@ -28,9 +28,9 @@ CREATE TABLE "Post"
CREATE TABLE "Source" CREATE TABLE "Source"
( (
id CHAR(25) PRIMARY KEY, id CHAR(25) PRIMARY KEY,
display_name TEXT NULL, display_name TEXT NULL,
icon TEXT NULL, icon TEXT NULL,
domain TEXT NOT NULL UNIQUE, domain TEXT NOT NULL UNIQUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP NULL deleted_at TIMESTAMP NULL
@ -47,7 +47,7 @@ CREATE TABLE "Tag"
CREATE TABLE "User" CREATE TABLE "User"
( (
id TEXT PRIMARY KEY, id TEXT PRIMARY KEY,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP NULL deleted_at TIMESTAMP NULL
@ -57,7 +57,7 @@ CREATE TABLE "PostReference"
( (
post_id TEXT REFERENCES "Post" (id), post_id TEXT REFERENCES "Post" (id),
source_id TEXT REFERENCES "Source" (id), source_id TEXT REFERENCES "Source" (id),
url TEXT NOT NULL, url TEXT NOT NULL,
full_file_url TEXT, full_file_url TEXT,
preview_file_url TEXT, preview_file_url TEXT,
sample_file_url TEXT, sample_file_url TEXT,
@ -79,16 +79,12 @@ CREATE TABLE "TagGroup"
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
); );
CREATE TABLE "UserFavorites"
(
user_id TEXT REFERENCES "User" (id),
post_id TEXT REFERENCES "Post" (id),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (user_id, post_id)
);
CREATE TABLE "UserSource" CREATE TABLE "UserSource"
( (
id CHAR(25) PRIMARY KEY,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP NULL NULL,
user_id TEXT REFERENCES "User" (id), user_id TEXT REFERENCES "User" (id),
source_id TEXT REFERENCES "Source" (id), source_id TEXT REFERENCES "Source" (id),
scrape_time_interval INT, scrape_time_interval INT,
@ -97,10 +93,20 @@ CREATE TABLE "UserSource"
last_scrape_time TIMESTAMP, last_scrape_time TIMESTAMP,
account_validate BOOL DEFAULT FALSE, account_validate BOOL DEFAULT FALSE,
account_validation_key CHAR(25), account_validation_key CHAR(25),
PRIMARY KEY (user_id, source_id),
UNIQUE (source_id, account_username, account_id) UNIQUE (source_id, account_username, account_id)
); );
CREATE TABLE "UserFavorites"
(
id CHAR(25) PRIMARY KEY,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP NULL NULL,
user_id TEXT REFERENCES "User" (id),
post_id TEXT REFERENCES "Post" (id),
user_source_id CHAR(25) REFERENCES "UserSource" (id)
);
CREATE TABLE "post_tags" CREATE TABLE "post_tags"
( (
post_id TEXT REFERENCES "Post" (id), post_id TEXT REFERENCES "Post" (id),