feat: reviews table added

This commit is contained in:
Iron_Felix 2025-11-16 04:15:33 +03:00
parent 47989ab10d
commit 29f0a61299
2 changed files with 31 additions and 0 deletions

View file

@ -24,6 +24,22 @@ CREATE TABLE images (
image_path text UNIQUE NOT NULL
);
CREATE TABLE reviews (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
data text NOT NULL,
rating int CHECK (rating >= 0 AND rating <= 10),
illust_id bigint REFERENCES images (id),
user_id bigint REFERENCES users (id),
title_id bigint REFERENCES titles (id),
created_at timestamptz DEFAULT NOW()
);
CREATE TABLE review_images (
PRIMARY KEY (review_id, image_id),
review_id bigint NOT NULL REFERENCES reviews(id) ON DELETE CASCADE,
image_id bigint NOT NULL REFERENCES images(id) ON DELETE CASCADE
);
CREATE TABLE users (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
avatar_id bigint REFERENCES images (id),