2026-11-20 06:41:21 +00:00
|
|
|
-- Stripe Checkout sessions started from the package cards. The package is
|
|
|
|
|
-- granted once, when the payment is confirmed (webhook, or the return page
|
|
|
|
|
-- asking Stripe), and the session id keeps that from happening twice.
|
|
|
|
|
CREATE TABLE stripe_checkouts (
|
|
|
|
|
-- Stripe's Checkout Session id (cs_test_… / cs_live_…).
|
2026-11-20 08:18:44 +00:00
|
|
|
id text PRIMARY KEY,
|
|
|
|
|
user_id uuid NOT NULL REFERENCES users ON DELETE CASCADE,
|
|
|
|
|
package text NOT NULL,
|
|
|
|
|
price_huf integer NOT NULL CHECK (price_huf > 0),
|
|
|
|
|
live boolean NOT NULL,
|
|
|
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
|
|
|
completed_at timestamptz,
|
|
|
|
|
order_id uuid REFERENCES package_orders ON DELETE SET NULL
|
2026-11-20 06:41:21 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
CREATE INDEX stripe_checkouts_user_idx ON stripe_checkouts (user_id, created_at DESC);
|