DROP TABLE IF EXISTS attribute;

-- DROP SEQUENCE IF EXISTS attribute_attribute_id_seq;
-- CREATE SEQUENCE attribute_attribute_id_seq;

CREATE TABLE "attribute" (
  "attribute_id" int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, -- SERIAL PRIMARY KEY
  "attribute_group_id" int check ("attribute_group_id" >= 0) NOT NULL,
  "sort_order" INT NOT NULL DEFAULT 0
 -- PRIMARY KEY("attribute_id")
);

SELECT setval('attribute_attribute_id_seq', 12, true); -- last inserted id by sample data
