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),

View file

@ -208,6 +208,21 @@ type Provider struct {
Credentials []byte `json:"credentials"`
}
type Review struct {
ID int64 `json:"id"`
Data string `json:"data"`
Rating *int32 `json:"rating"`
IllustID *int64 `json:"illust_id"`
UserID *int64 `json:"user_id"`
TitleID *int64 `json:"title_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
}
type ReviewImage struct {
ReviewID int64 `json:"review_id"`
ImageID int64 `json:"image_id"`
}
type Signal struct {
ID int64 `json:"id"`
TitleID *int64 `json:"title_id"`