DROP TABLE IF EXISTS currency;

-- DROP SEQUENCE IF EXISTS currency_currency_id_seq;
-- CREATE SEQUENCE currency_currency_id_seq;


CREATE TABLE currency (
  "currency_id" int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, -- SERIAL PRIMARY KEY
  "name" varchar(32) NOT NULL,
  "code" varchar(3) NOT NULL,
  "value" double precision NOT NULL DEFAULT 1,
  "sign_start" varchar(12) NOT NULL DEFAULT '',
  "sign_end" varchar(12) NOT NULL DEFAULT '',
  "decimal_place" smallint NOT NULL DEFAULT 2,
  "status" smallint NOT NULL DEFAULT 0,
  "updated_at" timestamp(0) NOT NULL DEFAULT now()
  -- PRIMARY KEY("currency_id")
);

SELECT setval('currency_currency_id_seq', 8, true); -- last inserted id by sample data
