DROP TABLE IF EXISTS tax_rate;


-- DROP SEQUENCE IF EXISTS tax_rate_tax_rate_id_seq;
-- CREATE SEQUENCE tax_rate_tax_rate_id_seq;


CREATE TABLE tax_rate (
  "tax_rate_id" int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, -- SERIAL PRIMARY KEY
  "region_group_id" int check ("region_group_id" > 0) NOT NULL DEFAULT 0,
  "name" varchar(32) NOT NULL,
  "rate" decimal(15,4) NOT NULL DEFAULT 0.0000,
  "type" char(1) NOT NULL,
  "created_at" timestamp(0) NOT NULL DEFAULT now(),
  "updated_at" timestamp(0) NOT NULL DEFAULT now()
  -- PRIMARY KEY("tax_rate_id")
);

SELECT setval('tax_rate_tax_rate_id_seq', 3, true); -- last inserted id by sample data