-- P5-5256 add designer teaser images

ALTER TABLE collections DROP CONSTRAINT IF EXISTS wallpaper_image_fk;
ALTER TABLE collections DROP CONSTRAINT IF EXISTS canvas_image_fk;
ALTER TABLE collections DROP CONSTRAINT IF EXISTS poster_image_fk;
ALTER TABLE collections DROP CONSTRAINT IF EXISTS framed_print_image_fk;

ALTER TABLE collections
  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;

ALTER TABLE collections 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 collections
    ADD CONSTRAINT wallpaper_image_fk
    FOREIGN KEY (wallpaper_image_id)
    REFERENCES teaser_images(id) MATCH SIMPLE
    ON DELETE SET NULL;

ALTER TABLE collections
    ADD CONSTRAINT canvas_image_fk
    FOREIGN KEY (canvas_image_id)
    REFERENCES teaser_images(id) MATCH SIMPLE
    ON DELETE SET NULL;

ALTER TABLE collections
    ADD CONSTRAINT poster_image_fk
    FOREIGN KEY (poster_image_id)
    REFERENCES teaser_images(id) MATCH SIMPLE
    ON DELETE SET NULL;

ALTER TABLE collections
    ADD CONSTRAINT framed_print_image_fk
    FOREIGN KEY (framed_print_image_id)
    REFERENCES teaser_images(id) MATCH SIMPLE
    ON DELETE SET NULL;
