DROP TABLE IF EXISTS "cart";

-- DROP SEQUENCE IF EXISTS cart_seq;
-- CREATE SEQUENCE cart_seq;

CREATE TABLE cart (
  "cart_id" int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, -- SERIAL PRIMARY KEY
  "user_id" int check ("user_id" >= -1) NOT NULL DEFAULT 0,
  "session_id" varchar(32) NOT NULL DEFAULT '',
  "data" text NOT NULL,
  "created_at"  timestamp(0) NOT NULL DEFAULT now()
  -- PRIMARY KEY("cart_id")
);

CREATE INDEX "cart_user_id" ON cart ("user_id");
CREATE INDEX "cart_session_id" ON cart ("session_id");
