* implement core foundation * inject deps * fix incorrect migration * tail migration * use transaction for migration * fix: inject deps for tests * cleanup billing management for admin * upgrade stripe sdk to v85 * set price env variables * cleanup billing management * allow multiple dev windows * fix: settings scroll * feat: show nice video thumbnail in listview * feat: implement freemium restrictions * remove unnecessary comments * refactor * docs * format * tweak network settings better hierarchy
29 lines
1.1 KiB
PL/PgSQL
29 lines
1.1 KiB
PL/PgSQL
BEGIN;
|
|
|
|
CREATE TABLE network_stripe_customers (
|
|
network_id TEXT PRIMARY KEY,
|
|
stripe_customer_id TEXT NOT NULL UNIQUE,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
);
|
|
|
|
CREATE TABLE network_subscriptions (
|
|
id TEXT PRIMARY KEY,
|
|
network_id TEXT NOT NULL REFERENCES network_stripe_customers(network_id) ON DELETE CASCADE,
|
|
stripe_customer_id TEXT NOT NULL,
|
|
status TEXT NOT NULL,
|
|
price_id TEXT NOT NULL,
|
|
cadence TEXT NOT NULL,
|
|
quantity INT NOT NULL,
|
|
cancel_at_period_end BOOLEAN NOT NULL DEFAULT FALSE,
|
|
current_period_start TIMESTAMPTZ NOT NULL,
|
|
current_period_end TIMESTAMPTZ NOT NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
CONSTRAINT network_subscriptions_cadence_check CHECK (cadence IN ('monthly', 'annual'))
|
|
);
|
|
|
|
CREATE UNIQUE INDEX idx_network_subscriptions_network_id
|
|
ON network_subscriptions (network_id);
|
|
|
|
COMMIT;
|