diff --git a/migrations/000.462.sql b/migrations/000.462.sql new file mode 100644 index 0000000..54508d3 --- /dev/null +++ b/migrations/000.462.sql @@ -0,0 +1,20 @@ +-- Store carts in database + +DROP TABLE IF EXISTS cart_cookies, cart_users, cart_sessions; + +CREATE TABLE cart_sessions ( + id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, + market_locale_id INTEGER NOT NULL REFERENCES market_locales (id), + public_id TEXT NOT NULL, + active BOOLEAN NOT NULL DEFAULT TRUE, + content TEXT, + revision INTEGER NOT NULL DEFAULT 0, + inactive_reason TEXT, + created timestamp with time zone NOT NULL DEFAULT now(), + last_modified timestamp with time zone NOT NULL DEFAULT now() +); +CREATE UNIQUE INDEX ON cart_sessions (public_id); + +-- last_modified reflects the last user interaction/modification of the cart. +-- It it not auto updated via trigger, to avoid having it update on non-user interactions, like us expiring the cart. +COMMENT ON COLUMN cart_sessions.last_modified IS 'Last update of cart contents';