5411 paint table (#393)
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
DROP TABLE IF EXISTS product_paint;
|
||||||
|
DROP TABLE IF EXISTS paint;
|
||||||
|
|
||||||
|
-- Create paint table
|
||||||
|
CREATE TABLE paint (
|
||||||
|
id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||||
|
color TEXT NOT NULL UNIQUE,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
path character varying(255) NOT NULL UNIQUE,
|
||||||
|
created timestamp with time zone NOT NULL DEFAULT now(),
|
||||||
|
updated timestamp with time zone DEFAULT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TRIGGER updated_timestamp BEFORE UPDATE ON paint FOR EACH ROW EXECUTE PROCEDURE updated_timestamp();
|
||||||
|
|
||||||
|
-- Insert mock paint data (for now)
|
||||||
|
INSERT INTO paint (color, name, path)
|
||||||
|
VALUES
|
||||||
|
('NCS S 5020-B90G', 'Sage Green', 'sage-green'),
|
||||||
|
('NCS S 1505-B', 'Ice Blue', 'ice-blue'),
|
||||||
|
('NCS S 1015-G', 'Breeze Green', 'breeze-green'),
|
||||||
|
('NCS S 0540-Y90R', 'Peachy', 'peachy'),
|
||||||
|
('NCS S 1060-R30B', 'Magenta', 'magenta');
|
||||||
|
|
||||||
|
-- Create product_paint table
|
||||||
|
CREATE TABLE product_paint (
|
||||||
|
product_id INTEGER NOT NULL REFERENCES "product-products"(productid) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
|
paint_id INTEGER NOT NULL REFERENCES paint(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
|
UNIQUE(product_id, paint_id)
|
||||||
|
);
|
||||||
|
|
||||||
Reference in New Issue
Block a user