Add collections and related tables

This commit is contained in:
Rikard Bartholf
2016-02-15 10:21:50 +01:00
parent bef3ebac57
commit 117caefdaa
+22 -1
View File
@@ -1 +1,22 @@
ALTER TABLE "collections-products" RENAME TO "collections_products";
CREATE TABLE public.collections (
id SERIAL NOT NULL,
name CHARACTER VARYING(255) NOT NULL,
inserted TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
updated TIMESTAMP WITH TIME ZONE,
designer_id INTEGER NOT NULL,
path CHARACTER VARYING(255) NOT NULL,
CONSTRAINT collections_pkey PRIMARY KEY (id),
FOREIGN KEY (designer_id) REFERENCES designers (designerid)
MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE
);
CREATE TABLE public.collections_products (
id SERIAL NOT NULL,
collection_id INTEGER NOT NULL,
product_id INTEGER,
CONSTRAINT collections_products_pkey PRIMARY KEY (id),
FOREIGN KEY (collection_id) REFERENCES collections (id)
MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (product_id) REFERENCES "product-products" (productid)
MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE
);