-- P5-303: Updated functionality of sales tab in society product
CREATE TABLE wallpapertypes
(
  id SERIAL NOT NULL,
  name VARCHAR(255),
  CONSTRAINT wallpapertypes_pkey PRIMARY KEY (id)
);

INSERT INTO wallpapertypes (name) VALUES ('wall_mural'), ('design_wallpaper');

CREATE TABLE product_wallpapertypes
(
  product_id INT NOT NULL,
  wallpapertype_id INT NOT NULL,

  CONSTRAINT product_wallpapertypes_pkey PRIMARY KEY (product_id, wallpapertype_id),

  CONSTRAINT wallpapertypes_id_fkey FOREIGN KEY (wallpapertype_id)
    REFERENCES wallpapertypes (id) MATCH SIMPLE
    ON UPDATE CASCADE ON DELETE CASCADE,

  CONSTRAINT "product-products_productid_fkey" FOREIGN KEY (product_id)
    REFERENCES "product-products" (productid) MATCH SIMPLE
    ON UPDATE CASCADE ON DELETE CASCADE
);
