5659 - add paint_card_samples table

This commit is contained in:
Anders Gustafsson
2024-07-02 10:41:09 +02:00
committed by GitHub
parent 6470ed6725
commit 3f67f6bffd
+17
View File
@@ -0,0 +1,17 @@
-- Drop what is created below for developer convenience
DROP TABLE IF EXISTS paint_card_samples;
-- Create paint primer table structure
-- Create paint_primer table
CREATE TABLE paint_card_samples (
id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
paint_id INTEGER NOT NULL REFERENCES paint(id),
stock INTEGER NOT NULL DEFAULT 0,
created timestamp with time zone NOT NULL DEFAULT now(),
updated timestamp with time zone DEFAULT NULL
);
CREATE TRIGGER updated_timestamp BEFORE UPDATE ON paint_card_samples FOR EACH ROW EXECUTE PROCEDURE updated_timestamp();
-- For each paint row add a paint_card_sample row with stock 1
INSERT INTO paint_card_samples (paint_id, stock) SELECT id, 1 FROM paint;