DROP TABLE IF EXISTS voucher_log;

-- DROP SEQUENCE IF EXISTS voucher_log_voucher_log_id_seq;
-- CREATE SEQUENCE voucher_log_voucher_log_id_seq;


CREATE TABLE voucher_log (
  "voucher_log_id" int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, -- SERIAL PRIMARY KEY
  "voucher_id" int check ("voucher_id" > 0) NOT NULL,
  "order_id" int check ("order_id" > 0) NOT NULL,
  "credit" decimal(15,4) NOT NULL,
  "created_at" timestamp(0) NOT NULL DEFAULT now()
  -- PRIMARY KEY("voucher_log_id")
);

-- SELECT setval('voucher_log_voucher_log_id_seq', 0, true); -- last inserted id by sample data