DROP TABLE IF EXISTS coupon_product;

-- DROP SEQUENCE IF EXISTS coupon_product_coupon_product_id_seq;
-- CREATE SEQUENCE coupon_product_coupon_product_id_seq;


CREATE TABLE coupon_product (
  "coupon_product_id" int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, -- SERIAL PRIMARY KEY
  "coupon_id" int check ("coupon_id" > 0) NOT NULL,
  "product_id" int check ("product_id" > 0) NOT NULL
  -- PRIMARY KEY("coupon_product_id")
);

CREATE INDEX "coupon_product_coupon_id" ON coupon_product ("coupon_id");
CREATE INDEX "coupon_product_product_id" ON coupon_product ("product_id");
-- SELECT setval('coupon_product_coupon_product_id_seq', 0, true); -- last inserted id by sample data
