feat(database): add ON DELETE CASCADE constraints
All checks were successful
Gitea Build Check / Build (pull_request) Successful in 3m5s
All checks were successful
Gitea Build Check / Build (pull_request) Successful in 3m5s
This commit is contained in:
parent
6f814e5b21
commit
ecbf139a9b
@ -91,7 +91,6 @@ CREATE TABLE "Tag"
|
|||||||
deleted_at TIMESTAMP WITH TIME ZONE NULL
|
deleted_at TIMESTAMP WITH TIME ZONE NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE "TagAlias"
|
CREATE TABLE "TagAlias"
|
||||||
(
|
(
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
@ -114,7 +113,7 @@ CREATE TABLE "UserSource"
|
|||||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||||
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||||
deleted_at TIMESTAMP WITH TIME ZONE NULL NULL,
|
deleted_at TIMESTAMP WITH TIME ZONE NULL NULL,
|
||||||
user_id CHAR(25) REFERENCES "User" (id),
|
user_id CHAR(25) REFERENCES "User" (id) ON DELETE CASCADE,
|
||||||
source_id TEXT REFERENCES "Source" (id),
|
source_id TEXT REFERENCES "Source" (id),
|
||||||
scrape_time_interval TEXT,
|
scrape_time_interval TEXT,
|
||||||
account_username TEXT,
|
account_username TEXT,
|
||||||
@ -131,9 +130,9 @@ CREATE TABLE "UserFavorites"
|
|||||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||||
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||||
deleted_at TIMESTAMP WITH TIME ZONE NULL NULL,
|
deleted_at TIMESTAMP WITH TIME ZONE NULL NULL,
|
||||||
user_id TEXT REFERENCES "User" (id),
|
user_id TEXT REFERENCES "User" (id) ON DELETE CASCADE,
|
||||||
post_id CHAR(25) REFERENCES "Post" (id),
|
post_id CHAR(25) REFERENCES "Post" (id),
|
||||||
user_source_id CHAR(25) REFERENCES "UserSource" (id)
|
user_source_id CHAR(25) REFERENCES "UserSource" (id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX idx_user_post_deleted ON "UserFavorites"(user_id, deleted_at);
|
CREATE INDEX idx_user_post_deleted ON "UserFavorites"(user_id, deleted_at);
|
||||||
@ -146,7 +145,6 @@ CREATE TABLE "post_tags"
|
|||||||
PRIMARY KEY (post_id, tag_id)
|
PRIMARY KEY (post_id, tag_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE "Pool"
|
CREATE TABLE "Pool"
|
||||||
(
|
(
|
||||||
id CHAR(25) PRIMARY KEY,
|
id CHAR(25) PRIMARY KEY,
|
||||||
@ -159,7 +157,7 @@ CREATE TABLE "Pool"
|
|||||||
|
|
||||||
CREATE TABLE "PoolPost"
|
CREATE TABLE "PoolPost"
|
||||||
(
|
(
|
||||||
pool_id CHAR(25) REFERENCES "Pool" (id),
|
pool_id CHAR(25) REFERENCES "Pool" (id) ON DELETE CASCADE,
|
||||||
post_id CHAR(25) REFERENCES "Post" (id),
|
post_id CHAR(25) REFERENCES "Post" (id),
|
||||||
order_position INT NOT NULL DEFAULT 0,
|
order_position INT NOT NULL DEFAULT 0,
|
||||||
PRIMARY KEY (pool_id, post_id)
|
PRIMARY KEY (pool_id, post_id)
|
||||||
@ -167,7 +165,7 @@ CREATE TABLE "PoolPost"
|
|||||||
|
|
||||||
CREATE TABLE "PoolReference"
|
CREATE TABLE "PoolReference"
|
||||||
(
|
(
|
||||||
pool_id CHAR(25) REFERENCES "Pool" (id),
|
pool_id CHAR(25) REFERENCES "Pool" (id) ON DELETE CASCADE,
|
||||||
source_id CHAR(25) REFERENCES "Source" (id),
|
source_id CHAR(25) REFERENCES "Source" (id),
|
||||||
url TEXT NOT NULL,
|
url TEXT NOT NULL,
|
||||||
PRIMARY KEY (pool_id, source_id, url)
|
PRIMARY KEY (pool_id, source_id, url)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user