DROP TABLE IF EXISTS order_total;

-- DROP SEQUENCE IF EXISTS order_total_order_total_id_seq;
-- CREATE SEQUENCE order_total_order_total_id_seq;


CREATE TABLE order_total (
  "order_total_id" int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, -- SERIAL PRIMARY KEY,
  "order_id" int check ("order_id" > 0) NOT NULL,
  "key" varchar(32) NOT NULL DEFAULT '',
  "title" varchar(191) NOT NULL,
  "value" decimal(15,4) NOT NULL DEFAULT 0.0000,
  "sort_order" int NOT NULL DEFAULT 0
  -- PRIMARY KEY("order_total_id")
);

CREATE INDEX "order_id" ON order_total ("order_id");
-- SELECT setval('order_total_order_total_id_seq', 0, true); -- last inserted id by sample data