-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vsilent
committed
Sep 3, 2023
1 parent
c1f4118
commit 374d906
Showing
4 changed files
with
37 additions
and
10 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- Add down migration script here | ||
|
||
DROP INDEX idx_category; | ||
DROP INDEX idx_user_id; | ||
DROP INDEX idx_product_id_rating_id; | ||
|
||
DROP table rating; | ||
DROP table product; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-- Add up migration script here | ||
|
||
CREATE TABLE product ( | ||
id integer NOT NULL, PRIMARY KEY(id), | ||
obj_id integer NOT NULL, | ||
obj_type TEXT NOT NULL, | ||
created_at timestamptz NOT NULL, | ||
updated_at timestamptz NOT NULL | ||
); | ||
|
||
CREATE TABLE rating ( | ||
id integer NOT NULL, PRIMARY KEY(id), | ||
user_id uuid NOT NULL, | ||
product_id integer NOT NULL, | ||
category VARCHAR(255) NOT NULL, | ||
comment TEXT DEFAULT NULL, | ||
hidden BOOLEAN DEFAULT FALSE, | ||
rate INTEGER, | ||
created_at timestamptz NOT NULL, | ||
updated_at timestamptz NOT NULL, | ||
CONSTRAINT fk_product | ||
FOREIGN KEY(product_id) | ||
REFERENCES product(id) | ||
); | ||
|
||
CREATE INDEX idx_category ON rating(category); | ||
CREATE INDEX idx_user_id ON rating(user_id); | ||
CREATE INDEX idx_product_id_rating_id ON rating(product_id, rate); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters