implement core foundation

This commit is contained in:
talksik
2026-04-14 11:00:46 -07:00
parent aff18d82db
commit 279a3e52c2
25 changed files with 1455 additions and 62 deletions
@@ -0,0 +1,2 @@
DROP TABLE IF EXISTS network_subscriptions;
DROP TABLE IF EXISTS network_stripe_customers;
@@ -0,0 +1,24 @@
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(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);