From 9dfb91a356a07d468a695dc736a48b04ac01a2b3 Mon Sep 17 00:00:00 2001 From: Rikard Bartholf Date: Mon, 15 Feb 2016 10:31:50 +0100 Subject: [PATCH] Add revised version of collections --- migrations/000.000.sql | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/migrations/000.000.sql b/migrations/000.000.sql index aa08d06..7577801 100644 --- a/migrations/000.000.sql +++ b/migrations/000.000.sql @@ -1,22 +1,27 @@ -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, +CREATE TABLE 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 + CONSTRAINT collections_designer_id_fkey 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, +CREATE TABLE 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 + CONSTRAINT collections_products_collection_id_fkey FOREIGN KEY (collection_id) + REFERENCES collections (id) 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 );