-- P5-5341 use teaser images table instead for categories

ALTER TABLE categories DROP CONSTRAINT IF EXISTS photo_wallpaper_image_fk;
ALTER TABLE categories DROP CONSTRAINT IF EXISTS design_wallpaper_image_fk;
ALTER TABLE categories DROP CONSTRAINT IF EXISTS canvas_image_fk;
ALTER TABLE categories DROP CONSTRAINT IF EXISTS poster_image_fk;
ALTER TABLE categories DROP CONSTRAINT IF EXISTS framed_print_image_fk;

ALTER TABLE categories
  DROP COLUMN IF EXISTS photo_wallpaper_image_id,
  DROP COLUMN IF EXISTS design_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 categories
    ADD COLUMN photo_wallpaper_image_id INTEGER,
    ADD COLUMN design_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 categories
    ADD CONSTRAINT photo_wallpaper_image_fk
    FOREIGN KEY (photo_wallpaper_image_id)
    REFERENCES teaser_images(id) MATCH SIMPLE
    ON DELETE SET NULL;

ALTER TABLE categories
    ADD CONSTRAINT design_wallpaper_image_fk
    FOREIGN KEY (design_wallpaper_image_id)
    REFERENCES teaser_images(id) MATCH SIMPLE
    ON DELETE SET NULL;

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

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

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

