12 lines
528 B
SQL
12 lines
528 B
SQL
CREATE TABLE IF NOT EXISTS trustpilot_ratings (
|
|
print_id INTEGER NOT NULL,
|
|
trustpilot_business_unit_id TEXT NOT NULL,
|
|
rating NUMERIC(3, 2) NOT NULL,
|
|
review_count INTEGER NOT NULL,
|
|
updated TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
|
|
PRIMARY KEY (print_id, trustpilot_business_unit_id),
|
|
FOREIGN KEY (print_id) REFERENCES "product-printproducts"(printid) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TRIGGER updated_timestamp BEFORE UPDATE ON trustpilot_ratings FOR EACH ROW EXECUTE PROCEDURE updated_timestamp();
|