Add revised version of collections

This commit is contained in:
Rikard Bartholf
2016-02-15 10:31:50 +01:00
parent 117caefdaa
commit 9dfb91a356
+22 -17
View File
@@ -1,22 +1,27 @@
CREATE TABLE public.collections ( CREATE TABLE collections
id SERIAL NOT NULL, (
name CHARACTER VARYING(255) NOT NULL, id serial NOT NULL,
inserted TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), name character varying(255) NOT NULL,
updated TIMESTAMP WITH TIME ZONE, inserted timestamp with time zone NOT NULL DEFAULT now(),
designer_id INTEGER NOT NULL, updated timestamp with time zone,
path CHARACTER VARYING(255) NOT NULL, designer_id integer NOT NULL,
path character varying(255) NOT NULL,
CONSTRAINT collections_pkey PRIMARY KEY (id), CONSTRAINT collections_pkey PRIMARY KEY (id),
FOREIGN KEY (designer_id) REFERENCES designers (designerid) CONSTRAINT collections_designer_id_fkey FOREIGN KEY (designer_id)
MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE REFERENCES designers (designerid) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE
); );
CREATE TABLE public.collections_products ( CREATE TABLE collections_products
id SERIAL NOT NULL, (
collection_id INTEGER NOT NULL, id serial NOT NULL,
product_id INTEGER, collection_id integer NOT NULL,
product_id integer,
CONSTRAINT collections_products_pkey PRIMARY KEY (id), CONSTRAINT collections_products_pkey PRIMARY KEY (id),
FOREIGN KEY (collection_id) REFERENCES collections (id) CONSTRAINT collections_products_collection_id_fkey FOREIGN KEY (collection_id)
MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE, REFERENCES collections (id) MATCH SIMPLE
FOREIGN KEY (product_id) REFERENCES "product-products" (productid) ON UPDATE CASCADE ON DELETE CASCADE,
MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE CONSTRAINT collections_products_product_id_fkey FOREIGN KEY (product_id)
REFERENCES "product-products" (productid) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE
); );