From 891f776051ccfcd31f253df65c4509cdde9c3e77 Mon Sep 17 00:00:00 2001 From: Niklas Fondberg Date: Thu, 4 Jun 2020 12:33:18 +0200 Subject: [PATCH] Add teaser images for designers --- migrations/000.201.sql | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 migrations/000.201.sql diff --git a/migrations/000.201.sql b/migrations/000.201.sql new file mode 100644 index 0000000..c393c26 --- /dev/null +++ b/migrations/000.201.sql @@ -0,0 +1,50 @@ +-- P5-5246 add designer teaser images + +ALTER TABLE designers DROP CONSTRAINT IF EXISTS wallpaper_image_fk; +ALTER TABLE designers DROP CONSTRAINT IF EXISTS canvas_image_fk; +ALTER TABLE designers DROP CONSTRAINT IF EXISTS poster_image_fk; +ALTER TABLE designers DROP CONSTRAINT IF EXISTS framed_print_image_fk; + +DROP TABLE IF EXISTS teaser_images; + +ALTER TABLE designers + DROP COLUMN IF EXISTS wallpaper_image_id, + DROP COLUMN IF EXISTS canvas_image_id, + DROP COLUMN IF EXISTS poster_image_id, + DROP COLUMN IF EXISTS framed_print_image_id; + +CREATE TABLE teaser_images +( + id SERIAL PRIMARY KEY, + key VARCHAR, + UNIQUE(key) +); + +ALTER TABLE designers ADD COLUMN wallpaper_image_id INTEGER, + ADD COLUMN canvas_image_id INTEGER, + ADD COLUMN poster_image_id INTEGER, + ADD COLUMN framed_print_image_id INTEGER; + +ALTER TABLE designers + ADD CONSTRAINT wallpaper_image_fk + FOREIGN KEY (wallpaper_image_id) + REFERENCES teaser_images(id) MATCH SIMPLE + ON DELETE SET NULL; + +ALTER TABLE designers + ADD CONSTRAINT canvas_image_fk + FOREIGN KEY (canvas_image_id) + REFERENCES teaser_images(id) MATCH SIMPLE + ON DELETE SET NULL; + +ALTER TABLE designers + ADD CONSTRAINT poster_image_fk + FOREIGN KEY (poster_image_id) + REFERENCES teaser_images(id) MATCH SIMPLE + ON DELETE SET NULL; + +ALTER TABLE designers + ADD CONSTRAINT framed_print_image_fk + FOREIGN KEY (framed_print_image_id) + REFERENCES teaser_images(id) MATCH SIMPLE + ON DELETE SET NULL;