DROP TABLE IF EXISTS region;

-- DROP SEQUENCE IF EXISTS region_region_id_seq;
-- CREATE SEQUENCE region_region_id_seq;

CREATE TABLE region (
  "region_id" int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, -- SERIAL PRIMARY KEY
  "country_id" int check ("country_id" > 0) NOT NULL,
  "name" varchar(128) NOT NULL,
  "code" varchar(32) NOT NULL,
  "status" smallint NOT NULL DEFAULT 1
  -- PRIMARY KEY("region_id")
);

CREATE INDEX "region_country_id" ON region ("country_id");
SELECT setval('region_region_id_seq', 4343, true); -- last inserted id by sample data
