Store carts sessions in database (#365)

This commit is contained in:
Fredrik Ringqvist
2024-02-29 11:55:45 +01:00
committed by GitHub
parent 272376477b
commit 92bfb391ad
+20
View File
@@ -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';