diff --git a/docs/early-access/architecture.md b/docs/early-access/architecture.md index e0fd73e8..9f90af1b 100644 --- a/docs/early-access/architecture.md +++ b/docs/early-access/architecture.md @@ -36,7 +36,8 @@ without PII and never stolen. ## Data ownership The schema compatibility barrel remains `lib/db/schema.ts`; domain definitions -move below `lib/db/schema/`. Append migration0007, never rewrite0000–0006. +move below `lib/db/schema/`. Never rewrite `0000`–`0004`. The unapplied tail is +squashed as `0005_early_access_foundation`. - Identity: users/authIdentities/userEmails; externalUserId becomes nullable legacy compatibility data. No new identity rows need a subject-derived alias. @@ -154,9 +155,9 @@ the obsolete guard. Existing production identifiers and token formats stay intac ## Contract amendment 3 — single-use OAuth code redemption -Independent review found inherited replayable authorization codes. Add migration -0008 with `oauth_code_redemptions`: unique SHA-256 code digest, expiration and -creation timestamps. No raw credentials are stored. After signature, PKCE and +Independent review found inherited replayable authorization codes. The squashed +`0005_early_access_foundation` migration includes `oauth_code_redemptions`: +unique SHA-256 code digest, expiration and creation timestamps. No raw credentials are stored. After signature, PKCE and approval validation, `consumeAuthorizationCode(code, expiresAt)` atomically inserts the digest before token minting; duplicate redemption is invalid_grant and storage failure is unavailable. A failed upstream mint still consumes the code; restart diff --git a/docs/early-access/migration-evidence.md b/docs/early-access/migration-evidence.md index 3527abf0..3e28d2a5 100644 --- a/docs/early-access/migration-evidence.md +++ b/docs/early-access/migration-evidence.md @@ -28,7 +28,7 @@ Outbox counts are a snapshot, not permission to process the backlog. `br-super-bird-auln2med` is the marked disposable test database, separate from both the old user-test preview and the new runtime preview. Migration test builds 0000–0004 in a transaction-local synthetic schema, seeds legacy fixtures, applies -0005–0007, verifies preserved counts, admin/subscription backfill idempotency, +squashed `0005_early_access_foundation`, verifies preserved counts, admin/subscription backfill idempotency, uniqueness/FKs, append-only audit, immutable aliases and synthetic grandfather dry-run/repeat application/revocation rejection, then rolls back. diff --git a/docs/waitlist-cutover.md b/docs/waitlist-cutover.md index 234b736a..6536856d 100644 --- a/docs/waitlist-cutover.md +++ b/docs/waitlist-cutover.md @@ -8,16 +8,14 @@ the only session accepted by `/admin`. ## Database boundaries - Migrations `0000` through `0004` reproduce the deployed waitlist schema. -- Migration `0005_canonical_user_foundation` adds `users`, - `auth_identities`, `user_emails`, and the nullable waitlist user link. -- Migration `0006_auth_identity_provider_metadata` records the Auth0 authority - and provider strategy on identities. Existing identities receive this metadata - on their next successful reconciliation. +- Migration `0005_early_access_foundation` is the unapplied tail: canonical + users (`users`, `auth_identities`, `user_emails`), identity metadata, early + access domains, OAuth code receipts, and the admin/subscription backfills. - Production uses the existing waitlist Postgres database. Preview deployments, CI, and destructive tests must use an isolated database branch. - Do not copy production records. Apply `0005` in place after taking the - provider's normal point-in-time backup and before enabling Console traffic; - then apply `0006`. Neither migration rewrites waitlist contact data. + provider's normal point-in-time backup and before enabling Console traffic. + It does not rewrite waitlist contact data. Authenticated requests keep the existing deterministic PymtHouse external user ID. A successful Auth0 login also best-effort upserts the application-owned user, @@ -43,7 +41,7 @@ scheduler until an explicitly configured Vercel cron replacement is tested. ## Staged release checklist -1. Deploy a preview with the isolated database and migrations `0000`-`0006`. +1. Deploy a preview with the isolated database and migrations `0000`-`0005`. 2. Verify `/waitlist`, signup delivery, `/verify`, referrals, consent changes, newsletter sync, admin access, CSV export, and outbox retries. 3. Verify Auth0 callback and repeat-login reconciliation, including verified and @@ -51,7 +49,7 @@ scheduler until an explicitly configured Vercel cron replacement is tested. 4. Smoke-test billing, keys, device approval, MCP discovery, and `/api/mcp`; the external PymtHouse identifier must match its pre-cutover value. 5. Record production counts for signups, confirmed members, consent events, and - pending outbox events. Apply `0005` and `0006`, deploy Console, and compare the counts. + pending outbox events. Apply `0005`, deploy Console, and compare the counts. 6. Move `earlyaccess.livepeer.org` only after the deployed checks pass. Retain the standalone waitlist deployment and its domain mapping as the rollback target until the observation window closes. diff --git a/drizzle/0005_canonical_user_foundation.sql b/drizzle/0005_canonical_user_foundation.sql deleted file mode 100644 index 4ca9163b..00000000 --- a/drizzle/0005_canonical_user_foundation.sql +++ /dev/null @@ -1,44 +0,0 @@ -CREATE TYPE "public"."user_status" AS ENUM('active', 'disabled');--> statement-breakpoint -CREATE TABLE "auth_identities" ( - "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, - "user_id" uuid NOT NULL, - "provider" text NOT NULL, - "provider_subject" text NOT NULL, - "external_user_id" text NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "last_seen_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "user_emails" ( - "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, - "user_id" uuid NOT NULL, - "email" text NOT NULL, - "normalized_email" text NOT NULL, - "source" text NOT NULL, - "is_primary" boolean DEFAULT false NOT NULL, - "verified_at" timestamp with time zone, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "users" ( - "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, - "status" "user_status" DEFAULT 'active' NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL, - "last_seen_at" timestamp with time zone DEFAULT now() NOT NULL, - "disabled_at" timestamp with time zone -); ---> statement-breakpoint -ALTER TABLE "waitlist_signups" ADD COLUMN "user_id" uuid;--> statement-breakpoint -ALTER TABLE "auth_identities" ADD CONSTRAINT "auth_identities_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "user_emails" ADD CONSTRAINT "user_emails_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE UNIQUE INDEX "auth_identities_provider_subject_idx" ON "auth_identities" USING btree ("provider","provider_subject");--> statement-breakpoint -CREATE UNIQUE INDEX "auth_identities_external_user_id_idx" ON "auth_identities" USING btree ("external_user_id");--> statement-breakpoint -CREATE INDEX "auth_identities_user_idx" ON "auth_identities" USING btree ("user_id");--> statement-breakpoint -CREATE UNIQUE INDEX "user_emails_user_normalized_idx" ON "user_emails" USING btree ("user_id","normalized_email");--> statement-breakpoint -CREATE UNIQUE INDEX "user_emails_verified_normalized_idx" ON "user_emails" USING btree ("normalized_email") WHERE "user_emails"."verified_at" is not null;--> statement-breakpoint -CREATE UNIQUE INDEX "user_emails_primary_user_idx" ON "user_emails" USING btree ("user_id") WHERE "user_emails"."is_primary" = true;--> statement-breakpoint -CREATE INDEX "users_status_idx" ON "users" USING btree ("status");--> statement-breakpoint -ALTER TABLE "waitlist_signups" ADD CONSTRAINT "waitlist_signups_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -CREATE UNIQUE INDEX "waitlist_signups_user_idx" ON "waitlist_signups" USING btree ("user_id") WHERE "waitlist_signups"."user_id" is not null; \ No newline at end of file diff --git a/drizzle/0007_early_access_domains.sql b/drizzle/0005_early_access_foundation.sql similarity index 80% rename from drizzle/0007_early_access_domains.sql rename to drizzle/0005_early_access_foundation.sql index 18f68734..7eaffe59 100644 --- a/drizzle/0007_early_access_domains.sql +++ b/drizzle/0005_early_access_foundation.sql @@ -1,3 +1,50 @@ +CREATE TYPE "public"."user_status" AS ENUM('active', 'disabled');--> statement-breakpoint +CREATE TABLE "auth_identities" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "user_id" uuid NOT NULL, + "provider" text NOT NULL, + "provider_subject" text NOT NULL, + "external_user_id" text NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "last_seen_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "user_emails" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "user_id" uuid NOT NULL, + "email" text NOT NULL, + "normalized_email" text NOT NULL, + "source" text NOT NULL, + "is_primary" boolean DEFAULT false NOT NULL, + "verified_at" timestamp with time zone, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "users" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "status" "user_status" DEFAULT 'active' NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + "last_seen_at" timestamp with time zone DEFAULT now() NOT NULL, + "disabled_at" timestamp with time zone +); +--> statement-breakpoint +ALTER TABLE "waitlist_signups" ADD COLUMN "user_id" uuid;--> statement-breakpoint +ALTER TABLE "auth_identities" ADD CONSTRAINT "auth_identities_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "user_emails" ADD CONSTRAINT "user_emails_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +CREATE UNIQUE INDEX "auth_identities_provider_subject_idx" ON "auth_identities" USING btree ("provider","provider_subject");--> statement-breakpoint +CREATE UNIQUE INDEX "auth_identities_external_user_id_idx" ON "auth_identities" USING btree ("external_user_id");--> statement-breakpoint +CREATE INDEX "auth_identities_user_idx" ON "auth_identities" USING btree ("user_id");--> statement-breakpoint +CREATE UNIQUE INDEX "user_emails_user_normalized_idx" ON "user_emails" USING btree ("user_id","normalized_email");--> statement-breakpoint +CREATE UNIQUE INDEX "user_emails_verified_normalized_idx" ON "user_emails" USING btree ("normalized_email") WHERE "user_emails"."verified_at" is not null;--> statement-breakpoint +CREATE UNIQUE INDEX "user_emails_primary_user_idx" ON "user_emails" USING btree ("user_id") WHERE "user_emails"."is_primary" = true;--> statement-breakpoint +CREATE INDEX "users_status_idx" ON "users" USING btree ("status");--> statement-breakpoint +ALTER TABLE "waitlist_signups" ADD CONSTRAINT "waitlist_signups_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +CREATE UNIQUE INDEX "waitlist_signups_user_idx" ON "waitlist_signups" USING btree ("user_id") WHERE "waitlist_signups"."user_id" is not null; +--> statement-breakpoint +ALTER TABLE "auth_identities" ADD COLUMN "provider_metadata" jsonb DEFAULT '{}'::jsonb NOT NULL; +--> statement-breakpoint CREATE TYPE "public"."access_grant_status" AS ENUM('approved', 'revoked');--> statement-breakpoint CREATE TYPE "public"."email_subscription_status" AS ENUM('subscribed', 'unsubscribed');--> statement-breakpoint CREATE TABLE "external_accounts" ( @@ -198,3 +245,9 @@ END; $$;--> statement-breakpoint CREATE TRIGGER external_accounts_preserve_mapping BEFORE UPDATE ON external_accounts FOR EACH ROW EXECUTE FUNCTION preserve_external_account_mapping(); +--> statement-breakpoint +CREATE TABLE "oauth_code_redemptions" ( + "code_hash" text PRIMARY KEY NOT NULL, + "expires_at" timestamp with time zone NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); diff --git a/drizzle/0006_auth_identity_provider_metadata.sql b/drizzle/0006_auth_identity_provider_metadata.sql deleted file mode 100644 index d50c9c99..00000000 --- a/drizzle/0006_auth_identity_provider_metadata.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "auth_identities" ADD COLUMN "provider_metadata" jsonb DEFAULT '{}'::jsonb NOT NULL; \ No newline at end of file diff --git a/drizzle/0008_oauth_code_redemptions.sql b/drizzle/0008_oauth_code_redemptions.sql deleted file mode 100644 index 083ff224..00000000 --- a/drizzle/0008_oauth_code_redemptions.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE "oauth_code_redemptions" ( - "code_hash" text PRIMARY KEY NOT NULL, - "expires_at" timestamp with time zone NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); diff --git a/drizzle/meta/0005_snapshot.json b/drizzle/meta/0005_snapshot.json index a780dbd4..cf3c81ff 100644 --- a/drizzle/meta/0005_snapshot.json +++ b/drizzle/meta/0005_snapshot.json @@ -1,11 +1,11 @@ { - "id": "15403f6f-1163-48ba-8670-19f0e0fa82d3", + "id": "cf11ffa6-05b1-446a-9a9f-bb1a11274046", "prevId": "b9a9912e-bd99-44eb-ae73-f8ef794cf7ab", "version": "7", "dialect": "postgresql", "tables": { - "public.attribution_touches": { - "name": "attribution_touches", + "public.auth_identities": { + "name": "auth_identities", "schema": "", "columns": { "id": { @@ -15,80 +15,24 @@ "notNull": true, "default": "gen_random_uuid()" }, - "signup_id": { - "name": "signup_id", + "user_id": { + "name": "user_id", "type": "uuid", "primaryKey": false, "notNull": true }, - "data": { - "name": "data", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "occurred_at": { - "name": "occurred_at", - "type": "timestamp with time zone", + "authority": { + "name": "authority", + "type": "text", "primaryKey": false, "notNull": true, - "default": "now()" - } - }, - "indexes": { - "attribution_touches_signup_idx": { - "name": "attribution_touches_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "attribution_touches_signup_id_waitlist_signups_id_fk": { - "name": "attribution_touches_signup_id_waitlist_signups_id_fk", - "tableFrom": "attribution_touches", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.auth_identities": { - "name": "auth_identities", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" + "default": "'auth0'" }, - "user_id": { - "name": "user_id", - "type": "uuid", + "issuer": { + "name": "issuer", + "type": "text", "primaryKey": false, - "notNull": true + "notNull": false }, "provider": { "name": "provider", @@ -102,11 +46,18 @@ "primaryKey": false, "notNull": true }, + "provider_metadata": { + "name": "provider_metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, "external_user_id": { "name": "external_user_id", "type": "text", "primaryKey": false, - "notNull": true + "notNull": false }, "created_at": { "name": "created_at", @@ -124,8 +75,36 @@ } }, "indexes": { - "auth_identities_provider_subject_idx": { - "name": "auth_identities_provider_subject_idx", + "auth_identities_authority_issuer_subject_idx": { + "name": "auth_identities_authority_issuer_subject_idx", + "columns": [ + { + "expression": "authority", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "issuer", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider_subject", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"auth_identities\".\"issuer\" is not null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "auth_identities_legacy_provider_subject_idx": { + "name": "auth_identities_legacy_provider_subject_idx", "columns": [ { "expression": "provider", @@ -141,6 +120,7 @@ } ], "isUnique": true, + "where": "\"auth_identities\".\"issuer\" is null", "concurrently": false, "method": "btree", "with": {} @@ -197,8 +177,8 @@ "checkConstraints": {}, "isRLSEnabled": false }, - "public.consent_events": { - "name": "consent_events", + "public.user_emails": { + "name": "user_emails", "schema": "", "columns": { "id": { @@ -208,26 +188,20 @@ "notNull": true, "default": "gen_random_uuid()" }, - "signup_id": { - "name": "signup_id", + "user_id": { + "name": "user_id", "type": "uuid", "primaryKey": false, "notNull": true }, - "purpose": { - "name": "purpose", + "email": { + "name": "email", "type": "text", "primaryKey": false, "notNull": true }, - "granted": { - "name": "granted", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "disclosure_version": { - "name": "disclosure_version", + "normalized_email": { + "name": "normalized_email", "type": "text", "primaryKey": false, "notNull": true @@ -238,8 +212,28 @@ "primaryKey": false, "notNull": true }, - "occurred_at": { - "name": "occurred_at", + "is_primary": { + "name": "is_primary", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "verified_at": { + "name": "verified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, @@ -247,29 +241,67 @@ } }, "indexes": { - "consent_events_signup_idx": { - "name": "consent_events_signup_idx", + "user_emails_user_normalized_idx": { + "name": "user_emails_user_normalized_idx", "columns": [ { - "expression": "signup_id", + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "normalized_email", "isExpression": false, "asc": true, "nulls": "last" } ], - "isUnique": false, + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_emails_verified_normalized_idx": { + "name": "user_emails_verified_normalized_idx", + "columns": [ + { + "expression": "normalized_email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"user_emails\".\"verified_at\" is not null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_emails_primary_user_idx": { + "name": "user_emails_primary_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"user_emails\".\"is_primary\" = true", "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { - "consent_events_signup_id_waitlist_signups_id_fk": { - "name": "consent_events_signup_id_waitlist_signups_id_fk", - "tableFrom": "consent_events", - "tableTo": "waitlist_signups", + "user_emails_user_id_users_id_fk": { + "name": "user_emails_user_id_users_id_fk", + "tableFrom": "user_emails", + "tableTo": "users", "columnsFrom": [ - "signup_id" + "user_id" ], "columnsTo": [ "id" @@ -284,8 +316,8 @@ "checkConstraints": {}, "isRLSEnabled": false }, - "public.email_outbox": { - "name": "email_outbox", + "public.users": { + "name": "users", "schema": "", "columns": { "id": { @@ -295,67 +327,1052 @@ "notNull": true, "default": "gen_random_uuid()" }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "idempotency_key": { - "name": "idempotency_key", - "type": "text", + "status": { + "name": "status", + "type": "user_status", + "typeSchema": "public", "primaryKey": false, - "notNull": true + "notNull": true, + "default": "'active'" }, - "attempt_count": { - "name": "attempt_count", - "type": "integer", + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", "primaryKey": false, "notNull": true, - "default": 0 + "default": "now()" }, - "next_attempt_at": { - "name": "next_attempt_at", + "updated_at": { + "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, - "locked_at": { - "name": "locked_at", + "last_seen_at": { + "name": "last_seen_at", "type": "timestamp with time zone", "primaryKey": false, - "notNull": false - }, + "notNull": true, + "default": "now()" + }, + "disabled_at": { + "name": "disabled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "users_status_idx": { + "name": "users_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.attribution_touches": { + "name": "attribution_touches", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "signup_id": { + "name": "signup_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "attribution_touches_signup_idx": { + "name": "attribution_touches_signup_idx", + "columns": [ + { + "expression": "signup_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "attribution_touches_signup_id_waitlist_signups_id_fk": { + "name": "attribution_touches_signup_id_waitlist_signups_id_fk", + "tableFrom": "attribution_touches", + "tableTo": "waitlist_signups", + "columnsFrom": [ + "signup_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.consent_events": { + "name": "consent_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "subscription_id": { + "name": "subscription_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "signup_id": { + "name": "signup_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "granted": { + "name": "granted", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "disclosure_version": { + "name": "disclosure_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "consent_events_signup_idx": { + "name": "consent_events_signup_idx", + "columns": [ + { + "expression": "signup_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "consent_events_subscription_id_email_subscriptions_id_fk": { + "name": "consent_events_subscription_id_email_subscriptions_id_fk", + "tableFrom": "consent_events", + "tableTo": "email_subscriptions", + "columnsFrom": [ + "subscription_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "consent_events_signup_id_waitlist_signups_id_fk": { + "name": "consent_events_signup_id_waitlist_signups_id_fk", + "tableFrom": "consent_events", + "tableTo": "waitlist_signups", + "columnsFrom": [ + "signup_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.email_outbox": { + "name": "email_outbox", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "signup_id": { + "name": "signup_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "attempt_count": { + "name": "attempt_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "locked_at": { + "name": "locked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, "terminal_at": { "name": "terminal_at", "type": "timestamp with time zone", "primaryKey": false, - "notNull": false + "notNull": false + }, + "last_error_code": { + "name": "last_error_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "processed_at": { + "name": "processed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "email_outbox_idempotency_idx": { + "name": "email_outbox_idempotency_idx", + "columns": [ + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "email_outbox_unprocessed_idx": { + "name": "email_outbox_unprocessed_idx", + "columns": [ + { + "expression": "processed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "email_outbox_signup_id_waitlist_signups_id_fk": { + "name": "email_outbox_signup_id_waitlist_signups_id_fk", + "tableFrom": "email_outbox", + "tableTo": "waitlist_signups", + "columnsFrom": [ + "signup_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.point_events": { + "name": "point_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "signup_id": { + "name": "signup_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "points": { + "name": "points", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "referral_signup_id": { + "name": "referral_signup_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "point_events_reason_referral_idx": { + "name": "point_events_reason_referral_idx", + "columns": [ + { + "expression": "reason", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "referral_signup_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "point_events_signup_idx": { + "name": "point_events_signup_idx", + "columns": [ + { + "expression": "signup_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "point_events_signup_id_waitlist_signups_id_fk": { + "name": "point_events_signup_id_waitlist_signups_id_fk", + "tableFrom": "point_events", + "tableTo": "waitlist_signups", + "columnsFrom": [ + "signup_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "point_events_referral_signup_id_waitlist_signups_id_fk": { + "name": "point_events_referral_signup_id_waitlist_signups_id_fk", + "tableFrom": "point_events", + "tableTo": "waitlist_signups", + "columnsFrom": [ + "referral_signup_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rate_limits": { + "name": "rate_limits", + "schema": "", + "columns": { + "key_hash": { + "name": "key_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bucket": { + "name": "bucket", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + } + }, + "indexes": { + "rate_limits_key_bucket_idx": { + "name": "rate_limits_key_bucket_idx", + "columns": [ + { + "expression": "key_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "bucket", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "signup_id": { + "name": "signup_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sessions_hash_idx": { + "name": "sessions_hash_idx", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sessions_signup_idx": { + "name": "sessions_signup_idx", + "columns": [ + { + "expression": "signup_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sessions_signup_id_waitlist_signups_id_fk": { + "name": "sessions_signup_id_waitlist_signups_id_fk", + "tableFrom": "sessions", + "tableTo": "waitlist_signups", + "columnsFrom": [ + "signup_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification_tokens": { + "name": "verification_tokens", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "signup_id": { + "name": "signup_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "requested_marketing_consent": { + "name": "requested_marketing_consent", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "consumed_at": { + "name": "consumed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "verification_tokens_hash_idx": { + "name": "verification_tokens_hash_idx", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "verification_tokens_signup_idx": { + "name": "verification_tokens_signup_idx", + "columns": [ + { + "expression": "signup_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "verification_tokens_signup_id_waitlist_signups_id_fk": { + "name": "verification_tokens_signup_id_waitlist_signups_id_fk", + "tableFrom": "verification_tokens", + "tableTo": "waitlist_signups", + "columnsFrom": [ + "signup_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.waitlist_signups": { + "name": "waitlist_signups", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "normalized_email": { + "name": "normalized_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "account_role": { + "name": "account_role", + "type": "account_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "enrollment_source": { + "name": "enrollment_source", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'waitlist'" + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "use_case": { + "name": "use_case", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "referral_code": { + "name": "referral_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "referred_by": { + "name": "referred_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "signup_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "marketing_consent": { + "name": "marketing_consent", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "first_touch": { + "name": "first_touch", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "last_touch": { + "name": "last_touch", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "confirmed_at": { + "name": "confirmed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "ip_hash": { + "name": "ip_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "waitlist_signups_normalized_email_idx": { + "name": "waitlist_signups_normalized_email_idx", + "columns": [ + { + "expression": "normalized_email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "waitlist_signups_referral_code_idx": { + "name": "waitlist_signups_referral_code_idx", + "columns": [ + { + "expression": "referral_code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "waitlist_signups_status_idx": { + "name": "waitlist_signups_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "waitlist_signups_user_idx": { + "name": "waitlist_signups_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"waitlist_signups\".\"user_id\" is not null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "waitlist_signups_referred_by_idx": { + "name": "waitlist_signups_referred_by_idx", + "columns": [ + { + "expression": "referred_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "waitlist_signups_confirmed_idx": { + "name": "waitlist_signups_confirmed_idx", + "columns": [ + { + "expression": "confirmed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "waitlist_signups_user_id_users_id_fk": { + "name": "waitlist_signups_user_id_users_id_fk", + "tableFrom": "waitlist_signups", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "waitlist_signups_referred_by_waitlist_signups_id_fk": { + "name": "waitlist_signups_referred_by_waitlist_signups_id_fk", + "tableFrom": "waitlist_signups", + "tableTo": "waitlist_signups", + "columnsFrom": [ + "referred_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.external_accounts": { + "name": "external_accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true }, - "last_error_code": { - "name": "last_error_code", + "service": { + "name": "service", "type": "text", "primaryKey": false, - "notNull": false + "notNull": true }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", + "issuer": { + "name": "issuer", + "type": "text", "primaryKey": false, - "notNull": false + "notNull": true + }, + "app_id": { + "name": "app_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "external_user_id": { + "name": "external_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true }, "created_at": { "name": "created_at", @@ -366,11 +1383,29 @@ } }, "indexes": { - "email_outbox_idempotency_idx": { - "name": "email_outbox_idempotency_idx", + "external_accounts_scope_external_idx": { + "name": "external_accounts_scope_external_idx", "columns": [ { - "expression": "idempotency_key", + "expression": "service", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "issuer", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "app_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_user_id", "isExpression": false, "asc": true, "nulls": "last" @@ -381,11 +1416,29 @@ "method": "btree", "with": {} }, - "email_outbox_unprocessed_idx": { - "name": "email_outbox_unprocessed_idx", + "external_accounts_user_scope_idx": { + "name": "external_accounts_user_scope_idx", "columns": [ { - "expression": "processed_at", + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "service", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "issuer", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "app_id", "isExpression": false, "asc": true, "nulls": "last" @@ -398,17 +1451,17 @@ } }, "foreignKeys": { - "email_outbox_signup_id_waitlist_signups_id_fk": { - "name": "email_outbox_signup_id_waitlist_signups_id_fk", - "tableFrom": "email_outbox", - "tableTo": "waitlist_signups", + "external_accounts_user_id_users_id_fk": { + "name": "external_accounts_user_id_users_id_fk", + "tableFrom": "external_accounts", + "tableTo": "users", "columnsFrom": [ - "signup_id" + "user_id" ], "columnsTo": [ "id" ], - "onDelete": "cascade", + "onDelete": "restrict", "onUpdate": "no action" } }, @@ -418,8 +1471,8 @@ "checkConstraints": {}, "isRLSEnabled": false }, - "public.point_events": { - "name": "point_events", + "public.identity_external_accounts": { + "name": "identity_external_accounts", "schema": "", "columns": { "id": { @@ -429,26 +1482,14 @@ "notNull": true, "default": "gen_random_uuid()" }, - "signup_id": { - "name": "signup_id", + "identity_id": { + "name": "identity_id", "type": "uuid", "primaryKey": false, "notNull": true }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "reason": { - "name": "reason", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "referral_signup_id": { - "name": "referral_signup_id", + "external_account_id": { + "name": "external_account_id", "type": "uuid", "primaryKey": false, "notNull": true @@ -462,17 +1503,17 @@ } }, "indexes": { - "point_events_reason_referral_idx": { - "name": "point_events_reason_referral_idx", + "identity_external_accounts_binding_idx": { + "name": "identity_external_accounts_binding_idx", "columns": [ { - "expression": "reason", + "expression": "identity_id", "isExpression": false, "asc": true, "nulls": "last" }, { - "expression": "referral_signup_id", + "expression": "external_account_id", "isExpression": false, "asc": true, "nulls": "last" @@ -483,11 +1524,11 @@ "method": "btree", "with": {} }, - "point_events_signup_idx": { - "name": "point_events_signup_idx", + "identity_external_accounts_account_idx": { + "name": "identity_external_accounts_account_idx", "columns": [ { - "expression": "signup_id", + "expression": "external_account_id", "isExpression": false, "asc": true, "nulls": "last" @@ -500,30 +1541,30 @@ } }, "foreignKeys": { - "point_events_signup_id_waitlist_signups_id_fk": { - "name": "point_events_signup_id_waitlist_signups_id_fk", - "tableFrom": "point_events", - "tableTo": "waitlist_signups", + "identity_external_accounts_identity_id_auth_identities_id_fk": { + "name": "identity_external_accounts_identity_id_auth_identities_id_fk", + "tableFrom": "identity_external_accounts", + "tableTo": "auth_identities", "columnsFrom": [ - "signup_id" + "identity_id" ], "columnsTo": [ "id" ], - "onDelete": "cascade", + "onDelete": "restrict", "onUpdate": "no action" }, - "point_events_referral_signup_id_waitlist_signups_id_fk": { - "name": "point_events_referral_signup_id_waitlist_signups_id_fk", - "tableFrom": "point_events", - "tableTo": "waitlist_signups", + "identity_external_accounts_external_account_id_external_accounts_id_fk": { + "name": "identity_external_accounts_external_account_id_external_accounts_id_fk", + "tableFrom": "identity_external_accounts", + "tableTo": "external_accounts", "columnsFrom": [ - "referral_signup_id" + "external_account_id" ], "columnsTo": [ "id" ], - "onDelete": "cascade", + "onDelete": "restrict", "onUpdate": "no action" } }, @@ -533,62 +1574,177 @@ "checkConstraints": {}, "isRLSEnabled": false }, - "public.rate_limits": { - "name": "rate_limits", + "public.access_events": { + "name": "access_events", "schema": "", "columns": { - "key_hash": { - "name": "key_hash", + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "grant_id": { + "name": "grant_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "actor_admin_grant_id": { + "name": "actor_admin_grant_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "operation_id": { + "name": "operation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", "type": "text", "primaryKey": false, "notNull": true }, - "bucket": { - "name": "bucket", - "type": "timestamp with time zone", + "source": { + "name": "source", + "type": "text", "primaryKey": false, "notNull": true }, - "attempts": { - "name": "attempts", + "previous_status": { + "name": "previous_status", + "type": "access_grant_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "next_status": { + "name": "next_status", + "type": "access_grant_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "grant_version": { + "name": "grant_version", "type": "integer", "primaryKey": false, + "notNull": true + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp with time zone", + "primaryKey": false, "notNull": true, - "default": 1 + "default": "now()" } }, "indexes": { - "rate_limits_key_bucket_idx": { - "name": "rate_limits_key_bucket_idx", + "access_events_operation_grant_idx": { + "name": "access_events_operation_grant_idx", "columns": [ { - "expression": "key_hash", + "expression": "operation_id", "isExpression": false, "asc": true, "nulls": "last" }, { - "expression": "bucket", + "expression": "grant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "access_events_grant_version_idx": { + "name": "access_events_grant_version_idx", + "columns": [ + { + "expression": "grant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "grant_version", "isExpression": false, "asc": true, "nulls": "last" } ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "access_events_grant_id_access_grants_id_fk": { + "name": "access_events_grant_id_access_grants_id_fk", + "tableFrom": "access_events", + "tableTo": "access_grants", + "columnsFrom": [ + "grant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "access_events_actor_admin_grant_id_admin_role_grants_id_fk": { + "name": "access_events_actor_admin_grant_id_admin_role_grants_id_fk", + "tableFrom": "access_events", + "tableTo": "admin_role_grants", + "columnsFrom": [ + "actor_admin_grant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "access_events_operation_id_access_operations_id_fk": { + "name": "access_events_operation_id_access_operations_id_fk", + "tableFrom": "access_events", + "tableTo": "access_operations", + "columnsFrom": [ + "operation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" } }, - "foreignKeys": {}, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, - "checkConstraints": {}, + "checkConstraints": { + "access_events_action_check": { + "name": "access_events_action_check", + "value": "\"access_events\".\"action\" in ('approve', 'revoke', 'activate', 'grandfather')" + }, + "access_events_version_check": { + "name": "access_events_version_check", + "value": "\"access_events\".\"grant_version\" > 0" + } + }, "isRLSEnabled": false }, - "public.sessions": { - "name": "sessions", + "public.access_grants": { + "name": "access_grants", "schema": "", "columns": { "id": { @@ -598,23 +1754,43 @@ "notNull": true, "default": "gen_random_uuid()" }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, "signup_id": { "name": "signup_id", "type": "uuid", "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "access_grant_status", + "typeSchema": "public", + "primaryKey": false, "notNull": true }, - "token_hash": { - "name": "token_hash", + "source": { + "name": "source", "type": "text", "primaryKey": false, "notNull": true }, - "expires_at": { - "name": "expires_at", + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "approved_at": { + "name": "approved_at", "type": "timestamp with time zone", "primaryKey": false, - "notNull": true + "notNull": false }, "revoked_at": { "name": "revoked_at", @@ -622,32 +1798,46 @@ "primaryKey": false, "notNull": false }, + "activated_at": { + "name": "activated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, "created_at": { "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" } }, "indexes": { - "sessions_hash_idx": { - "name": "sessions_hash_idx", + "access_grants_user_idx": { + "name": "access_grants_user_idx", "columns": [ { - "expression": "token_hash", + "expression": "user_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, + "where": "\"access_grants\".\"user_id\" is not null", "concurrently": false, "method": "btree", "with": {} }, - "sessions_signup_idx": { - "name": "sessions_signup_idx", + "access_grants_signup_idx": { + "name": "access_grants_signup_idx", "columns": [ { "expression": "signup_id", @@ -656,6 +1846,22 @@ "nulls": "last" } ], + "isUnique": true, + "where": "\"access_grants\".\"signup_id\" is not null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "access_grants_status_idx": { + "name": "access_grants_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], "isUnique": false, "concurrently": false, "method": "btree", @@ -663,9 +1869,22 @@ } }, "foreignKeys": { - "sessions_signup_id_waitlist_signups_id_fk": { - "name": "sessions_signup_id_waitlist_signups_id_fk", - "tableFrom": "sessions", + "access_grants_user_id_users_id_fk": { + "name": "access_grants_user_id_users_id_fk", + "tableFrom": "access_grants", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "access_grants_signup_id_waitlist_signups_id_fk": { + "name": "access_grants_signup_id_waitlist_signups_id_fk", + "tableFrom": "access_grants", "tableTo": "waitlist_signups", "columnsFrom": [ "signup_id" @@ -673,18 +1892,27 @@ "columnsTo": [ "id" ], - "onDelete": "cascade", + "onDelete": "restrict", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, - "checkConstraints": {}, + "checkConstraints": { + "access_grants_target_check": { + "name": "access_grants_target_check", + "value": "\"access_grants\".\"user_id\" is not null or \"access_grants\".\"signup_id\" is not null" + }, + "access_grants_version_check": { + "name": "access_grants_version_check", + "value": "\"access_grants\".\"version\" > 0" + } + }, "isRLSEnabled": false }, - "public.user_emails": { - "name": "user_emails", + "public.access_operation_items": { + "name": "access_operation_items", "schema": "", "columns": { "id": { @@ -694,49 +1922,35 @@ "notNull": true, "default": "gen_random_uuid()" }, - "user_id": { - "name": "user_id", + "operation_id": { + "name": "operation_id", "type": "uuid", "primaryKey": false, "notNull": true }, - "email": { - "name": "email", - "type": "text", + "signup_id": { + "name": "signup_id", + "type": "uuid", "primaryKey": false, "notNull": true }, - "normalized_email": { - "name": "normalized_email", + "outcome": { + "name": "outcome", "type": "text", "primaryKey": false, "notNull": true }, - "source": { - "name": "source", + "code": { + "name": "code", "type": "text", "primaryKey": false, - "notNull": true - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "verified_at": { - "name": "verified_at", - "type": "timestamp with time zone", - "primaryKey": false, "notNull": false }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", + "event_id": { + "name": "event_id", + "type": "uuid", "primaryKey": false, - "notNull": true, - "default": "now()" + "notNull": false }, "updated_at": { "name": "updated_at", @@ -747,83 +1961,82 @@ } }, "indexes": { - "user_emails_user_normalized_idx": { - "name": "user_emails_user_normalized_idx", + "access_operation_items_operation_signup_idx": { + "name": "access_operation_items_operation_signup_idx", "columns": [ { - "expression": "user_id", + "expression": "operation_id", "isExpression": false, "asc": true, "nulls": "last" }, { - "expression": "normalized_email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "user_emails_verified_normalized_idx": { - "name": "user_emails_verified_normalized_idx", - "columns": [ - { - "expression": "normalized_email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"user_emails\".\"verified_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "user_emails_primary_user_idx": { - "name": "user_emails_primary_user_idx", - "columns": [ - { - "expression": "user_id", + "expression": "signup_id", "isExpression": false, "asc": true, "nulls": "last" } ], "isUnique": true, - "where": "\"user_emails\".\"is_primary\" = true", "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { - "user_emails_user_id_users_id_fk": { - "name": "user_emails_user_id_users_id_fk", - "tableFrom": "user_emails", - "tableTo": "users", + "access_operation_items_operation_id_access_operations_id_fk": { + "name": "access_operation_items_operation_id_access_operations_id_fk", + "tableFrom": "access_operation_items", + "tableTo": "access_operations", "columnsFrom": [ - "user_id" + "operation_id" ], "columnsTo": [ "id" ], - "onDelete": "cascade", + "onDelete": "restrict", + "onUpdate": "no action" + }, + "access_operation_items_signup_id_waitlist_signups_id_fk": { + "name": "access_operation_items_signup_id_waitlist_signups_id_fk", + "tableFrom": "access_operation_items", + "tableTo": "waitlist_signups", + "columnsFrom": [ + "signup_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "access_operation_items_event_id_access_events_id_fk": { + "name": "access_operation_items_event_id_access_events_id_fk", + "tableFrom": "access_operation_items", + "tableTo": "access_events", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, - "checkConstraints": {}, + "checkConstraints": { + "access_operation_items_outcome_check": { + "name": "access_operation_items_outcome_check", + "value": "\"access_operation_items\".\"outcome\" in ('approved', 'revoked', 'unchanged', 'ineligible', 'failed')" + } + }, "isRLSEnabled": false }, - "public.users": { - "name": "users", + "public.access_operations": { + "name": "access_operations", "schema": "", "columns": { "id": { @@ -833,68 +2046,89 @@ "notNull": true, "default": "gen_random_uuid()" }, - "status": { - "name": "status", - "type": "user_status", - "typeSchema": "public", + "actor_admin_grant_id": { + "name": "actor_admin_grant_id", + "type": "uuid", "primaryKey": false, - "notNull": true, - "default": "'active'" + "notNull": true }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", + "request_id": { + "name": "request_id", + "type": "text", "primaryKey": false, - "notNull": true, - "default": "now()" + "notNull": true }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", + "action": { + "name": "action", + "type": "text", "primaryKey": false, - "notNull": true, - "default": "now()" + "notNull": true }, - "last_seen_at": { - "name": "last_seen_at", - "type": "timestamp with time zone", + "payload_hash": { + "name": "payload_hash", + "type": "text", "primaryKey": false, - "notNull": true, - "default": "now()" + "notNull": true }, - "disabled_at": { - "name": "disabled_at", + "created_at": { + "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, - "notNull": false + "notNull": true, + "default": "now()" } }, "indexes": { - "users_status_idx": { - "name": "users_status_idx", + "access_operations_actor_request_idx": { + "name": "access_operations_actor_request_idx", "columns": [ { - "expression": "status", + "expression": "actor_admin_grant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "request_id", "isExpression": false, "asc": true, "nulls": "last" } ], - "isUnique": false, + "isUnique": true, "concurrently": false, "method": "btree", "with": {} } }, - "foreignKeys": {}, + "foreignKeys": { + "access_operations_actor_admin_grant_id_admin_role_grants_id_fk": { + "name": "access_operations_actor_admin_grant_id_admin_role_grants_id_fk", + "tableFrom": "access_operations", + "tableTo": "admin_role_grants", + "columnsFrom": [ + "actor_admin_grant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, - "checkConstraints": {}, + "checkConstraints": { + "access_operations_action_check": { + "name": "access_operations_action_check", + "value": "\"access_operations\".\"action\" in ('approve', 'revoke')" + } + }, "isRLSEnabled": false }, - "public.verification_tokens": { - "name": "verification_tokens", + "public.admin_role_grants": { + "name": "admin_role_grants", "schema": "", "columns": { "id": { @@ -904,81 +2138,66 @@ "notNull": true, "default": "gen_random_uuid()" }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "token_hash": { - "name": "token_hash", - "type": "text", + "signup_id": { + "name": "signup_id", + "type": "uuid", "primaryKey": false, "notNull": true }, - "requested_marketing_consent": { - "name": "requested_marketing_consent", - "type": "boolean", + "role": { + "name": "role", + "type": "text", "primaryKey": false, "notNull": true, - "default": false + "default": "'admin'" }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", + "source": { + "name": "source", + "type": "text", "primaryKey": false, "notNull": true }, - "consumed_at": { - "name": "consumed_at", + "granted_at": { + "name": "granted_at", "type": "timestamp with time zone", "primaryKey": false, - "notNull": false + "notNull": true, + "default": "now()" }, - "created_at": { - "name": "created_at", + "revoked_at": { + "name": "revoked_at", "type": "timestamp with time zone", "primaryKey": false, - "notNull": true, - "default": "now()" + "notNull": false } }, "indexes": { - "verification_tokens_hash_idx": { - "name": "verification_tokens_hash_idx", + "admin_role_grants_signup_role_idx": { + "name": "admin_role_grants_signup_role_idx", "columns": [ { - "expression": "token_hash", + "expression": "signup_id", "isExpression": false, "asc": true, "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "verification_tokens_signup_idx": { - "name": "verification_tokens_signup_idx", - "columns": [ + }, { - "expression": "signup_id", + "expression": "role", "isExpression": false, "asc": true, "nulls": "last" } ], - "isUnique": false, + "isUnique": true, "concurrently": false, "method": "btree", "with": {} } }, "foreignKeys": { - "verification_tokens_signup_id_waitlist_signups_id_fk": { - "name": "verification_tokens_signup_id_waitlist_signups_id_fk", - "tableFrom": "verification_tokens", + "admin_role_grants_signup_id_waitlist_signups_id_fk": { + "name": "admin_role_grants_signup_id_waitlist_signups_id_fk", + "tableFrom": "admin_role_grants", "tableTo": "waitlist_signups", "columnsFrom": [ "signup_id" @@ -986,18 +2205,55 @@ "columnsTo": [ "id" ], - "onDelete": "cascade", + "onDelete": "restrict", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, + "checkConstraints": { + "admin_role_grants_role_check": { + "name": "admin_role_grants_role_check", + "value": "\"admin_role_grants\".\"role\" = 'admin'" + } + }, + "isRLSEnabled": false + }, + "public.oauth_code_redemptions": { + "name": "oauth_code_redemptions", + "schema": "", + "columns": { + "code_hash": { + "name": "code_hash", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, "checkConstraints": {}, "isRLSEnabled": false }, - "public.waitlist_signups": { - "name": "waitlist_signups", + "public.email_subscriptions": { + "name": "email_subscriptions", "schema": "", "columns": { "id": { @@ -1007,139 +2263,71 @@ "notNull": true, "default": "gen_random_uuid()" }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, "normalized_email": { "name": "normalized_email", "type": "text", "primaryKey": false, "notNull": true }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "account_role": { - "name": "account_role", - "type": "account_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'member'" - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - }, - "use_case": { - "name": "use_case", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - }, - "referral_code": { - "name": "referral_code", + "purpose": { + "name": "purpose", "type": "text", "primaryKey": false, "notNull": true }, - "referred_by": { - "name": "referred_by", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, "status": { "name": "status", - "type": "signup_status", + "type": "email_subscription_status", "typeSchema": "public", "primaryKey": false, "notNull": true, - "default": "'pending'" + "default": "'unsubscribed'" }, - "marketing_consent": { - "name": "marketing_consent", - "type": "boolean", + "user_id": { + "name": "user_id", + "type": "uuid", "primaryKey": false, - "notNull": true, - "default": false + "notNull": false }, - "first_touch": { - "name": "first_touch", - "type": "jsonb", + "signup_id": { + "name": "signup_id", + "type": "uuid", "primaryKey": false, - "notNull": true + "notNull": false }, - "last_touch": { - "name": "last_touch", - "type": "jsonb", + "source": { + "name": "source", + "type": "text", "primaryKey": false, "notNull": true }, - "first_seen_at": { - "name": "first_seen_at", + "created_at": { + "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, - "last_seen_at": { - "name": "last_seen_at", + "updated_at": { + "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, "default": "now()" - }, - "confirmed_at": { - "name": "confirmed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "ip_hash": { - "name": "ip_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "text", - "primaryKey": false, - "notNull": false } }, "indexes": { - "waitlist_signups_normalized_email_idx": { - "name": "waitlist_signups_normalized_email_idx", + "email_subscriptions_address_purpose_idx": { + "name": "email_subscriptions_address_purpose_idx", "columns": [ { "expression": "normalized_email", "isExpression": false, "asc": true, "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "waitlist_signups_referral_code_idx": { - "name": "waitlist_signups_referral_code_idx", - "columns": [ + }, { - "expression": "referral_code", + "expression": "purpose", "isExpression": false, "asc": true, "nulls": "last" @@ -1150,23 +2338,8 @@ "method": "btree", "with": {} }, - "waitlist_signups_status_idx": { - "name": "waitlist_signups_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "waitlist_signups_user_idx": { - "name": "waitlist_signups_user_idx", + "email_subscriptions_user_idx": { + "name": "email_subscriptions_user_idx", "columns": [ { "expression": "user_id", @@ -1175,38 +2348,16 @@ "nulls": "last" } ], - "isUnique": true, - "where": "\"waitlist_signups\".\"user_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "waitlist_signups_referred_by_idx": { - "name": "waitlist_signups_referred_by_idx", - "columns": [ - { - "expression": "referred_by", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], "isUnique": false, "concurrently": false, "method": "btree", "with": {} }, - "waitlist_signups_confirmed_idx": { - "name": "waitlist_signups_confirmed_idx", + "email_subscriptions_signup_idx": { + "name": "email_subscriptions_signup_idx", "columns": [ { - "expression": "confirmed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", + "expression": "signup_id", "isExpression": false, "asc": true, "nulls": "last" @@ -1219,9 +2370,9 @@ } }, "foreignKeys": { - "waitlist_signups_user_id_users_id_fk": { - "name": "waitlist_signups_user_id_users_id_fk", - "tableFrom": "waitlist_signups", + "email_subscriptions_user_id_users_id_fk": { + "name": "email_subscriptions_user_id_users_id_fk", + "tableFrom": "email_subscriptions", "tableTo": "users", "columnsFrom": [ "user_id" @@ -1232,12 +2383,12 @@ "onDelete": "set null", "onUpdate": "no action" }, - "waitlist_signups_referred_by_waitlist_signups_id_fk": { - "name": "waitlist_signups_referred_by_waitlist_signups_id_fk", - "tableFrom": "waitlist_signups", + "email_subscriptions_signup_id_waitlist_signups_id_fk": { + "name": "email_subscriptions_signup_id_waitlist_signups_id_fk", + "tableFrom": "email_subscriptions", "tableTo": "waitlist_signups", "columnsFrom": [ - "referred_by" + "signup_id" ], "columnsTo": [ "id" @@ -1254,6 +2405,14 @@ } }, "enums": { + "public.user_status": { + "name": "user_status", + "schema": "public", + "values": [ + "active", + "disabled" + ] + }, "public.account_role": { "name": "account_role", "schema": "public", @@ -1273,12 +2432,20 @@ "suppressed" ] }, - "public.user_status": { - "name": "user_status", + "public.access_grant_status": { + "name": "access_grant_status", "schema": "public", "values": [ - "active", - "disabled" + "approved", + "revoked" + ] + }, + "public.email_subscription_status": { + "name": "email_subscription_status", + "schema": "public", + "values": [ + "subscribed", + "unsubscribed" ] } }, @@ -1292,4 +2459,4 @@ "schemas": {}, "tables": {} } -} \ No newline at end of file +} diff --git a/drizzle/meta/0006_snapshot.json b/drizzle/meta/0006_snapshot.json deleted file mode 100644 index ead7a868..00000000 --- a/drizzle/meta/0006_snapshot.json +++ /dev/null @@ -1,1302 +0,0 @@ -{ - "id": "476ac650-bfb6-459a-a7da-1a73aa0405b1", - "prevId": "15403f6f-1163-48ba-8670-19f0e0fa82d3", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.attribution_touches": { - "name": "attribution_touches", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "data": { - "name": "data", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "occurred_at": { - "name": "occurred_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "attribution_touches_signup_idx": { - "name": "attribution_touches_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "attribution_touches_signup_id_waitlist_signups_id_fk": { - "name": "attribution_touches_signup_id_waitlist_signups_id_fk", - "tableFrom": "attribution_touches", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.auth_identities": { - "name": "auth_identities", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider_subject": { - "name": "provider_subject", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider_metadata": { - "name": "provider_metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "external_user_id": { - "name": "external_user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_seen_at": { - "name": "last_seen_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "auth_identities_provider_subject_idx": { - "name": "auth_identities_provider_subject_idx", - "columns": [ - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider_subject", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "auth_identities_external_user_id_idx": { - "name": "auth_identities_external_user_id_idx", - "columns": [ - { - "expression": "external_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "auth_identities_user_idx": { - "name": "auth_identities_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "auth_identities_user_id_users_id_fk": { - "name": "auth_identities_user_id_users_id_fk", - "tableFrom": "auth_identities", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.consent_events": { - "name": "consent_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "purpose": { - "name": "purpose", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "granted": { - "name": "granted", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "disclosure_version": { - "name": "disclosure_version", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "occurred_at": { - "name": "occurred_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "consent_events_signup_idx": { - "name": "consent_events_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "consent_events_signup_id_waitlist_signups_id_fk": { - "name": "consent_events_signup_id_waitlist_signups_id_fk", - "tableFrom": "consent_events", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.email_outbox": { - "name": "email_outbox", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "idempotency_key": { - "name": "idempotency_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "attempt_count": { - "name": "attempt_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "locked_at": { - "name": "locked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "terminal_at": { - "name": "terminal_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "email_outbox_idempotency_idx": { - "name": "email_outbox_idempotency_idx", - "columns": [ - { - "expression": "idempotency_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "email_outbox_unprocessed_idx": { - "name": "email_outbox_unprocessed_idx", - "columns": [ - { - "expression": "processed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "email_outbox_signup_id_waitlist_signups_id_fk": { - "name": "email_outbox_signup_id_waitlist_signups_id_fk", - "tableFrom": "email_outbox", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.point_events": { - "name": "point_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "reason": { - "name": "reason", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "referral_signup_id": { - "name": "referral_signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "point_events_reason_referral_idx": { - "name": "point_events_reason_referral_idx", - "columns": [ - { - "expression": "reason", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "referral_signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "point_events_signup_idx": { - "name": "point_events_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "point_events_signup_id_waitlist_signups_id_fk": { - "name": "point_events_signup_id_waitlist_signups_id_fk", - "tableFrom": "point_events", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "point_events_referral_signup_id_waitlist_signups_id_fk": { - "name": "point_events_referral_signup_id_waitlist_signups_id_fk", - "tableFrom": "point_events", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "referral_signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.rate_limits": { - "name": "rate_limits", - "schema": "", - "columns": { - "key_hash": { - "name": "key_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "bucket": { - "name": "bucket", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "attempts": { - "name": "attempts", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - } - }, - "indexes": { - "rate_limits_key_bucket_idx": { - "name": "rate_limits_key_bucket_idx", - "columns": [ - { - "expression": "key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "bucket", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.sessions": { - "name": "sessions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "token_hash": { - "name": "token_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "revoked_at": { - "name": "revoked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "sessions_hash_idx": { - "name": "sessions_hash_idx", - "columns": [ - { - "expression": "token_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "sessions_signup_idx": { - "name": "sessions_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "sessions_signup_id_waitlist_signups_id_fk": { - "name": "sessions_signup_id_waitlist_signups_id_fk", - "tableFrom": "sessions", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.user_emails": { - "name": "user_emails", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "normalized_email": { - "name": "normalized_email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "verified_at": { - "name": "verified_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "user_emails_user_normalized_idx": { - "name": "user_emails_user_normalized_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "normalized_email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "user_emails_verified_normalized_idx": { - "name": "user_emails_verified_normalized_idx", - "columns": [ - { - "expression": "normalized_email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"user_emails\".\"verified_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "user_emails_primary_user_idx": { - "name": "user_emails_primary_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"user_emails\".\"is_primary\" = true", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "user_emails_user_id_users_id_fk": { - "name": "user_emails_user_id_users_id_fk", - "tableFrom": "user_emails", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "status": { - "name": "status", - "type": "user_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_seen_at": { - "name": "last_seen_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "users_status_idx": { - "name": "users_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.verification_tokens": { - "name": "verification_tokens", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "token_hash": { - "name": "token_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "requested_marketing_consent": { - "name": "requested_marketing_consent", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "consumed_at": { - "name": "consumed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "verification_tokens_hash_idx": { - "name": "verification_tokens_hash_idx", - "columns": [ - { - "expression": "token_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "verification_tokens_signup_idx": { - "name": "verification_tokens_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "verification_tokens_signup_id_waitlist_signups_id_fk": { - "name": "verification_tokens_signup_id_waitlist_signups_id_fk", - "tableFrom": "verification_tokens", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.waitlist_signups": { - "name": "waitlist_signups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "normalized_email": { - "name": "normalized_email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "account_role": { - "name": "account_role", - "type": "account_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'member'" - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - }, - "use_case": { - "name": "use_case", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - }, - "referral_code": { - "name": "referral_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "referred_by": { - "name": "referred_by", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "signup_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "marketing_consent": { - "name": "marketing_consent", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "first_touch": { - "name": "first_touch", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "last_touch": { - "name": "last_touch", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "first_seen_at": { - "name": "first_seen_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_seen_at": { - "name": "last_seen_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "confirmed_at": { - "name": "confirmed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "ip_hash": { - "name": "ip_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "waitlist_signups_normalized_email_idx": { - "name": "waitlist_signups_normalized_email_idx", - "columns": [ - { - "expression": "normalized_email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "waitlist_signups_referral_code_idx": { - "name": "waitlist_signups_referral_code_idx", - "columns": [ - { - "expression": "referral_code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "waitlist_signups_status_idx": { - "name": "waitlist_signups_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "waitlist_signups_user_idx": { - "name": "waitlist_signups_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"waitlist_signups\".\"user_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "waitlist_signups_referred_by_idx": { - "name": "waitlist_signups_referred_by_idx", - "columns": [ - { - "expression": "referred_by", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "waitlist_signups_confirmed_idx": { - "name": "waitlist_signups_confirmed_idx", - "columns": [ - { - "expression": "confirmed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "waitlist_signups_user_id_users_id_fk": { - "name": "waitlist_signups_user_id_users_id_fk", - "tableFrom": "waitlist_signups", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "waitlist_signups_referred_by_waitlist_signups_id_fk": { - "name": "waitlist_signups_referred_by_waitlist_signups_id_fk", - "tableFrom": "waitlist_signups", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "referred_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": { - "public.account_role": { - "name": "account_role", - "schema": "public", - "values": [ - "member", - "admin" - ] - }, - "public.signup_status": { - "name": "signup_status", - "schema": "public", - "values": [ - "pending", - "confirmed", - "invited", - "unsubscribed", - "suppressed" - ] - }, - "public.user_status": { - "name": "user_status", - "schema": "public", - "values": [ - "active", - "disabled" - ] - } - }, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0007_snapshot.json b/drizzle/meta/0007_snapshot.json deleted file mode 100644 index 5ca18129..00000000 --- a/drizzle/meta/0007_snapshot.json +++ /dev/null @@ -1,2430 +0,0 @@ -{ - "id": "ff203db9-07e7-4f06-aaa7-40719bd28d57", - "prevId": "476ac650-bfb6-459a-a7da-1a73aa0405b1", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.auth_identities": { - "name": "auth_identities", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "authority": { - "name": "authority", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'auth0'" - }, - "issuer": { - "name": "issuer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider_subject": { - "name": "provider_subject", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider_metadata": { - "name": "provider_metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "external_user_id": { - "name": "external_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_seen_at": { - "name": "last_seen_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "auth_identities_authority_issuer_subject_idx": { - "name": "auth_identities_authority_issuer_subject_idx", - "columns": [ - { - "expression": "authority", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "issuer", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider_subject", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"auth_identities\".\"issuer\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "auth_identities_legacy_provider_subject_idx": { - "name": "auth_identities_legacy_provider_subject_idx", - "columns": [ - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider_subject", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"auth_identities\".\"issuer\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "auth_identities_external_user_id_idx": { - "name": "auth_identities_external_user_id_idx", - "columns": [ - { - "expression": "external_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "auth_identities_user_idx": { - "name": "auth_identities_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "auth_identities_user_id_users_id_fk": { - "name": "auth_identities_user_id_users_id_fk", - "tableFrom": "auth_identities", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.user_emails": { - "name": "user_emails", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "normalized_email": { - "name": "normalized_email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "verified_at": { - "name": "verified_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "user_emails_user_normalized_idx": { - "name": "user_emails_user_normalized_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "normalized_email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "user_emails_verified_normalized_idx": { - "name": "user_emails_verified_normalized_idx", - "columns": [ - { - "expression": "normalized_email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"user_emails\".\"verified_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "user_emails_primary_user_idx": { - "name": "user_emails_primary_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"user_emails\".\"is_primary\" = true", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "user_emails_user_id_users_id_fk": { - "name": "user_emails_user_id_users_id_fk", - "tableFrom": "user_emails", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "status": { - "name": "status", - "type": "user_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_seen_at": { - "name": "last_seen_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "users_status_idx": { - "name": "users_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.attribution_touches": { - "name": "attribution_touches", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "data": { - "name": "data", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "occurred_at": { - "name": "occurred_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "attribution_touches_signup_idx": { - "name": "attribution_touches_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "attribution_touches_signup_id_waitlist_signups_id_fk": { - "name": "attribution_touches_signup_id_waitlist_signups_id_fk", - "tableFrom": "attribution_touches", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.consent_events": { - "name": "consent_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "subscription_id": { - "name": "subscription_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "purpose": { - "name": "purpose", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "granted": { - "name": "granted", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "disclosure_version": { - "name": "disclosure_version", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "occurred_at": { - "name": "occurred_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "consent_events_signup_idx": { - "name": "consent_events_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "consent_events_subscription_id_email_subscriptions_id_fk": { - "name": "consent_events_subscription_id_email_subscriptions_id_fk", - "tableFrom": "consent_events", - "tableTo": "email_subscriptions", - "columnsFrom": [ - "subscription_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "consent_events_signup_id_waitlist_signups_id_fk": { - "name": "consent_events_signup_id_waitlist_signups_id_fk", - "tableFrom": "consent_events", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.email_outbox": { - "name": "email_outbox", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "idempotency_key": { - "name": "idempotency_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "attempt_count": { - "name": "attempt_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "locked_at": { - "name": "locked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "terminal_at": { - "name": "terminal_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "email_outbox_idempotency_idx": { - "name": "email_outbox_idempotency_idx", - "columns": [ - { - "expression": "idempotency_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "email_outbox_unprocessed_idx": { - "name": "email_outbox_unprocessed_idx", - "columns": [ - { - "expression": "processed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "email_outbox_signup_id_waitlist_signups_id_fk": { - "name": "email_outbox_signup_id_waitlist_signups_id_fk", - "tableFrom": "email_outbox", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.point_events": { - "name": "point_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "reason": { - "name": "reason", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "referral_signup_id": { - "name": "referral_signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "point_events_reason_referral_idx": { - "name": "point_events_reason_referral_idx", - "columns": [ - { - "expression": "reason", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "referral_signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "point_events_signup_idx": { - "name": "point_events_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "point_events_signup_id_waitlist_signups_id_fk": { - "name": "point_events_signup_id_waitlist_signups_id_fk", - "tableFrom": "point_events", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "point_events_referral_signup_id_waitlist_signups_id_fk": { - "name": "point_events_referral_signup_id_waitlist_signups_id_fk", - "tableFrom": "point_events", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "referral_signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.rate_limits": { - "name": "rate_limits", - "schema": "", - "columns": { - "key_hash": { - "name": "key_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "bucket": { - "name": "bucket", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "attempts": { - "name": "attempts", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - } - }, - "indexes": { - "rate_limits_key_bucket_idx": { - "name": "rate_limits_key_bucket_idx", - "columns": [ - { - "expression": "key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "bucket", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.sessions": { - "name": "sessions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "token_hash": { - "name": "token_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "revoked_at": { - "name": "revoked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "sessions_hash_idx": { - "name": "sessions_hash_idx", - "columns": [ - { - "expression": "token_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "sessions_signup_idx": { - "name": "sessions_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "sessions_signup_id_waitlist_signups_id_fk": { - "name": "sessions_signup_id_waitlist_signups_id_fk", - "tableFrom": "sessions", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.verification_tokens": { - "name": "verification_tokens", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "token_hash": { - "name": "token_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "requested_marketing_consent": { - "name": "requested_marketing_consent", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "consumed_at": { - "name": "consumed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "verification_tokens_hash_idx": { - "name": "verification_tokens_hash_idx", - "columns": [ - { - "expression": "token_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "verification_tokens_signup_idx": { - "name": "verification_tokens_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "verification_tokens_signup_id_waitlist_signups_id_fk": { - "name": "verification_tokens_signup_id_waitlist_signups_id_fk", - "tableFrom": "verification_tokens", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.waitlist_signups": { - "name": "waitlist_signups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "normalized_email": { - "name": "normalized_email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "account_role": { - "name": "account_role", - "type": "account_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'member'" - }, - "enrollment_source": { - "name": "enrollment_source", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'waitlist'" - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - }, - "use_case": { - "name": "use_case", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - }, - "referral_code": { - "name": "referral_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "referred_by": { - "name": "referred_by", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "signup_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "marketing_consent": { - "name": "marketing_consent", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "first_touch": { - "name": "first_touch", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "last_touch": { - "name": "last_touch", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "first_seen_at": { - "name": "first_seen_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_seen_at": { - "name": "last_seen_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "confirmed_at": { - "name": "confirmed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "ip_hash": { - "name": "ip_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "waitlist_signups_normalized_email_idx": { - "name": "waitlist_signups_normalized_email_idx", - "columns": [ - { - "expression": "normalized_email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "waitlist_signups_referral_code_idx": { - "name": "waitlist_signups_referral_code_idx", - "columns": [ - { - "expression": "referral_code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "waitlist_signups_status_idx": { - "name": "waitlist_signups_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "waitlist_signups_user_idx": { - "name": "waitlist_signups_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"waitlist_signups\".\"user_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "waitlist_signups_referred_by_idx": { - "name": "waitlist_signups_referred_by_idx", - "columns": [ - { - "expression": "referred_by", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "waitlist_signups_confirmed_idx": { - "name": "waitlist_signups_confirmed_idx", - "columns": [ - { - "expression": "confirmed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "waitlist_signups_user_id_users_id_fk": { - "name": "waitlist_signups_user_id_users_id_fk", - "tableFrom": "waitlist_signups", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "waitlist_signups_referred_by_waitlist_signups_id_fk": { - "name": "waitlist_signups_referred_by_waitlist_signups_id_fk", - "tableFrom": "waitlist_signups", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "referred_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.external_accounts": { - "name": "external_accounts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "service": { - "name": "service", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "issuer": { - "name": "issuer", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "app_id": { - "name": "app_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "external_user_id": { - "name": "external_user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "external_accounts_scope_external_idx": { - "name": "external_accounts_scope_external_idx", - "columns": [ - { - "expression": "service", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "issuer", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "app_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "external_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "external_accounts_user_scope_idx": { - "name": "external_accounts_user_scope_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "service", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "issuer", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "app_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "external_accounts_user_id_users_id_fk": { - "name": "external_accounts_user_id_users_id_fk", - "tableFrom": "external_accounts", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.identity_external_accounts": { - "name": "identity_external_accounts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "identity_id": { - "name": "identity_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "external_account_id": { - "name": "external_account_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "identity_external_accounts_binding_idx": { - "name": "identity_external_accounts_binding_idx", - "columns": [ - { - "expression": "identity_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "external_account_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "identity_external_accounts_account_idx": { - "name": "identity_external_accounts_account_idx", - "columns": [ - { - "expression": "external_account_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "identity_external_accounts_identity_id_auth_identities_id_fk": { - "name": "identity_external_accounts_identity_id_auth_identities_id_fk", - "tableFrom": "identity_external_accounts", - "tableTo": "auth_identities", - "columnsFrom": [ - "identity_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "identity_external_accounts_external_account_id_external_accounts_id_fk": { - "name": "identity_external_accounts_external_account_id_external_accounts_id_fk", - "tableFrom": "identity_external_accounts", - "tableTo": "external_accounts", - "columnsFrom": [ - "external_account_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.access_events": { - "name": "access_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "grant_id": { - "name": "grant_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "actor_admin_grant_id": { - "name": "actor_admin_grant_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "operation_id": { - "name": "operation_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "previous_status": { - "name": "previous_status", - "type": "access_grant_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": false - }, - "next_status": { - "name": "next_status", - "type": "access_grant_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "grant_version": { - "name": "grant_version", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "occurred_at": { - "name": "occurred_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "access_events_operation_grant_idx": { - "name": "access_events_operation_grant_idx", - "columns": [ - { - "expression": "operation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "grant_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "access_events_grant_version_idx": { - "name": "access_events_grant_version_idx", - "columns": [ - { - "expression": "grant_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "grant_version", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "access_events_grant_id_access_grants_id_fk": { - "name": "access_events_grant_id_access_grants_id_fk", - "tableFrom": "access_events", - "tableTo": "access_grants", - "columnsFrom": [ - "grant_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "access_events_actor_admin_grant_id_admin_role_grants_id_fk": { - "name": "access_events_actor_admin_grant_id_admin_role_grants_id_fk", - "tableFrom": "access_events", - "tableTo": "admin_role_grants", - "columnsFrom": [ - "actor_admin_grant_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "access_events_operation_id_access_operations_id_fk": { - "name": "access_events_operation_id_access_operations_id_fk", - "tableFrom": "access_events", - "tableTo": "access_operations", - "columnsFrom": [ - "operation_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "access_events_action_check": { - "name": "access_events_action_check", - "value": "\"access_events\".\"action\" in ('approve', 'revoke', 'activate', 'grandfather')" - }, - "access_events_version_check": { - "name": "access_events_version_check", - "value": "\"access_events\".\"grant_version\" > 0" - } - }, - "isRLSEnabled": false - }, - "public.access_grants": { - "name": "access_grants", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "access_grant_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "version": { - "name": "version", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "approved_at": { - "name": "approved_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revoked_at": { - "name": "revoked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "activated_at": { - "name": "activated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "access_grants_user_idx": { - "name": "access_grants_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"access_grants\".\"user_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "access_grants_signup_idx": { - "name": "access_grants_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"access_grants\".\"signup_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "access_grants_status_idx": { - "name": "access_grants_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "access_grants_user_id_users_id_fk": { - "name": "access_grants_user_id_users_id_fk", - "tableFrom": "access_grants", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "access_grants_signup_id_waitlist_signups_id_fk": { - "name": "access_grants_signup_id_waitlist_signups_id_fk", - "tableFrom": "access_grants", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "access_grants_target_check": { - "name": "access_grants_target_check", - "value": "\"access_grants\".\"user_id\" is not null or \"access_grants\".\"signup_id\" is not null" - }, - "access_grants_version_check": { - "name": "access_grants_version_check", - "value": "\"access_grants\".\"version\" > 0" - } - }, - "isRLSEnabled": false - }, - "public.access_operation_items": { - "name": "access_operation_items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "operation_id": { - "name": "operation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "outcome": { - "name": "outcome", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "event_id": { - "name": "event_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "access_operation_items_operation_signup_idx": { - "name": "access_operation_items_operation_signup_idx", - "columns": [ - { - "expression": "operation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "access_operation_items_operation_id_access_operations_id_fk": { - "name": "access_operation_items_operation_id_access_operations_id_fk", - "tableFrom": "access_operation_items", - "tableTo": "access_operations", - "columnsFrom": [ - "operation_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "access_operation_items_signup_id_waitlist_signups_id_fk": { - "name": "access_operation_items_signup_id_waitlist_signups_id_fk", - "tableFrom": "access_operation_items", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "access_operation_items_event_id_access_events_id_fk": { - "name": "access_operation_items_event_id_access_events_id_fk", - "tableFrom": "access_operation_items", - "tableTo": "access_events", - "columnsFrom": [ - "event_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "access_operation_items_outcome_check": { - "name": "access_operation_items_outcome_check", - "value": "\"access_operation_items\".\"outcome\" in ('approved', 'revoked', 'unchanged', 'ineligible', 'failed')" - } - }, - "isRLSEnabled": false - }, - "public.access_operations": { - "name": "access_operations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "actor_admin_grant_id": { - "name": "actor_admin_grant_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "request_id": { - "name": "request_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "payload_hash": { - "name": "payload_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "access_operations_actor_request_idx": { - "name": "access_operations_actor_request_idx", - "columns": [ - { - "expression": "actor_admin_grant_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "request_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "access_operations_actor_admin_grant_id_admin_role_grants_id_fk": { - "name": "access_operations_actor_admin_grant_id_admin_role_grants_id_fk", - "tableFrom": "access_operations", - "tableTo": "admin_role_grants", - "columnsFrom": [ - "actor_admin_grant_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "access_operations_action_check": { - "name": "access_operations_action_check", - "value": "\"access_operations\".\"action\" in ('approve', 'revoke')" - } - }, - "isRLSEnabled": false - }, - "public.admin_role_grants": { - "name": "admin_role_grants", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'admin'" - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "granted_at": { - "name": "granted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "revoked_at": { - "name": "revoked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "admin_role_grants_signup_role_idx": { - "name": "admin_role_grants_signup_role_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "role", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "admin_role_grants_signup_id_waitlist_signups_id_fk": { - "name": "admin_role_grants_signup_id_waitlist_signups_id_fk", - "tableFrom": "admin_role_grants", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "admin_role_grants_role_check": { - "name": "admin_role_grants_role_check", - "value": "\"admin_role_grants\".\"role\" = 'admin'" - } - }, - "isRLSEnabled": false - }, - "public.email_subscriptions": { - "name": "email_subscriptions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "normalized_email": { - "name": "normalized_email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "purpose": { - "name": "purpose", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "email_subscription_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'unsubscribed'" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "email_subscriptions_address_purpose_idx": { - "name": "email_subscriptions_address_purpose_idx", - "columns": [ - { - "expression": "normalized_email", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "purpose", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "email_subscriptions_user_idx": { - "name": "email_subscriptions_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "email_subscriptions_signup_idx": { - "name": "email_subscriptions_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "email_subscriptions_user_id_users_id_fk": { - "name": "email_subscriptions_user_id_users_id_fk", - "tableFrom": "email_subscriptions", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "email_subscriptions_signup_id_waitlist_signups_id_fk": { - "name": "email_subscriptions_signup_id_waitlist_signups_id_fk", - "tableFrom": "email_subscriptions", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": { - "public.user_status": { - "name": "user_status", - "schema": "public", - "values": [ - "active", - "disabled" - ] - }, - "public.account_role": { - "name": "account_role", - "schema": "public", - "values": [ - "member", - "admin" - ] - }, - "public.signup_status": { - "name": "signup_status", - "schema": "public", - "values": [ - "pending", - "confirmed", - "invited", - "unsubscribed", - "suppressed" - ] - }, - "public.access_grant_status": { - "name": "access_grant_status", - "schema": "public", - "values": [ - "approved", - "revoked" - ] - }, - "public.email_subscription_status": { - "name": "email_subscription_status", - "schema": "public", - "values": [ - "subscribed", - "unsubscribed" - ] - } - }, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0008_snapshot.json b/drizzle/meta/0008_snapshot.json deleted file mode 100644 index 4701c55f..00000000 --- a/drizzle/meta/0008_snapshot.json +++ /dev/null @@ -1,2462 +0,0 @@ -{ - "id": "e4954eb9-4c53-496a-a66e-553fc2d72837", - "prevId": "ff203db9-07e7-4f06-aaa7-40719bd28d57", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.auth_identities": { - "name": "auth_identities", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "authority": { - "name": "authority", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'auth0'" - }, - "issuer": { - "name": "issuer", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider_subject": { - "name": "provider_subject", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider_metadata": { - "name": "provider_metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "external_user_id": { - "name": "external_user_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_seen_at": { - "name": "last_seen_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "auth_identities_authority_issuer_subject_idx": { - "name": "auth_identities_authority_issuer_subject_idx", - "columns": [ - { - "expression": "authority", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "issuer", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider_subject", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"auth_identities\".\"issuer\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "auth_identities_legacy_provider_subject_idx": { - "name": "auth_identities_legacy_provider_subject_idx", - "columns": [ - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider_subject", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"auth_identities\".\"issuer\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "auth_identities_external_user_id_idx": { - "name": "auth_identities_external_user_id_idx", - "columns": [ - { - "expression": "external_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "auth_identities_user_idx": { - "name": "auth_identities_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "auth_identities_user_id_users_id_fk": { - "name": "auth_identities_user_id_users_id_fk", - "tableFrom": "auth_identities", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.user_emails": { - "name": "user_emails", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "normalized_email": { - "name": "normalized_email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_primary": { - "name": "is_primary", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "verified_at": { - "name": "verified_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "user_emails_user_normalized_idx": { - "name": "user_emails_user_normalized_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "normalized_email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "user_emails_verified_normalized_idx": { - "name": "user_emails_verified_normalized_idx", - "columns": [ - { - "expression": "normalized_email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"user_emails\".\"verified_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "user_emails_primary_user_idx": { - "name": "user_emails_primary_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"user_emails\".\"is_primary\" = true", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "user_emails_user_id_users_id_fk": { - "name": "user_emails_user_id_users_id_fk", - "tableFrom": "user_emails", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "status": { - "name": "status", - "type": "user_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_seen_at": { - "name": "last_seen_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "users_status_idx": { - "name": "users_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.attribution_touches": { - "name": "attribution_touches", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "data": { - "name": "data", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "occurred_at": { - "name": "occurred_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "attribution_touches_signup_idx": { - "name": "attribution_touches_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "attribution_touches_signup_id_waitlist_signups_id_fk": { - "name": "attribution_touches_signup_id_waitlist_signups_id_fk", - "tableFrom": "attribution_touches", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.consent_events": { - "name": "consent_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "subscription_id": { - "name": "subscription_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "purpose": { - "name": "purpose", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "granted": { - "name": "granted", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "disclosure_version": { - "name": "disclosure_version", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "occurred_at": { - "name": "occurred_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "consent_events_signup_idx": { - "name": "consent_events_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "consent_events_subscription_id_email_subscriptions_id_fk": { - "name": "consent_events_subscription_id_email_subscriptions_id_fk", - "tableFrom": "consent_events", - "tableTo": "email_subscriptions", - "columnsFrom": [ - "subscription_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "consent_events_signup_id_waitlist_signups_id_fk": { - "name": "consent_events_signup_id_waitlist_signups_id_fk", - "tableFrom": "consent_events", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.email_outbox": { - "name": "email_outbox", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "idempotency_key": { - "name": "idempotency_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "attempt_count": { - "name": "attempt_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "locked_at": { - "name": "locked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "terminal_at": { - "name": "terminal_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "email_outbox_idempotency_idx": { - "name": "email_outbox_idempotency_idx", - "columns": [ - { - "expression": "idempotency_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "email_outbox_unprocessed_idx": { - "name": "email_outbox_unprocessed_idx", - "columns": [ - { - "expression": "processed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "email_outbox_signup_id_waitlist_signups_id_fk": { - "name": "email_outbox_signup_id_waitlist_signups_id_fk", - "tableFrom": "email_outbox", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.point_events": { - "name": "point_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "reason": { - "name": "reason", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "referral_signup_id": { - "name": "referral_signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "point_events_reason_referral_idx": { - "name": "point_events_reason_referral_idx", - "columns": [ - { - "expression": "reason", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "referral_signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "point_events_signup_idx": { - "name": "point_events_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "point_events_signup_id_waitlist_signups_id_fk": { - "name": "point_events_signup_id_waitlist_signups_id_fk", - "tableFrom": "point_events", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "point_events_referral_signup_id_waitlist_signups_id_fk": { - "name": "point_events_referral_signup_id_waitlist_signups_id_fk", - "tableFrom": "point_events", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "referral_signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.rate_limits": { - "name": "rate_limits", - "schema": "", - "columns": { - "key_hash": { - "name": "key_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "bucket": { - "name": "bucket", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "attempts": { - "name": "attempts", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - } - }, - "indexes": { - "rate_limits_key_bucket_idx": { - "name": "rate_limits_key_bucket_idx", - "columns": [ - { - "expression": "key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "bucket", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.sessions": { - "name": "sessions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "token_hash": { - "name": "token_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "revoked_at": { - "name": "revoked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "sessions_hash_idx": { - "name": "sessions_hash_idx", - "columns": [ - { - "expression": "token_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "sessions_signup_idx": { - "name": "sessions_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "sessions_signup_id_waitlist_signups_id_fk": { - "name": "sessions_signup_id_waitlist_signups_id_fk", - "tableFrom": "sessions", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.verification_tokens": { - "name": "verification_tokens", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "token_hash": { - "name": "token_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "requested_marketing_consent": { - "name": "requested_marketing_consent", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "consumed_at": { - "name": "consumed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "verification_tokens_hash_idx": { - "name": "verification_tokens_hash_idx", - "columns": [ - { - "expression": "token_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "verification_tokens_signup_idx": { - "name": "verification_tokens_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "verification_tokens_signup_id_waitlist_signups_id_fk": { - "name": "verification_tokens_signup_id_waitlist_signups_id_fk", - "tableFrom": "verification_tokens", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.waitlist_signups": { - "name": "waitlist_signups", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "normalized_email": { - "name": "normalized_email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "account_role": { - "name": "account_role", - "type": "account_role", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'member'" - }, - "enrollment_source": { - "name": "enrollment_source", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'waitlist'" - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - }, - "use_case": { - "name": "use_case", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "''" - }, - "referral_code": { - "name": "referral_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "referred_by": { - "name": "referred_by", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "signup_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "marketing_consent": { - "name": "marketing_consent", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "first_touch": { - "name": "first_touch", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "last_touch": { - "name": "last_touch", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "first_seen_at": { - "name": "first_seen_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_seen_at": { - "name": "last_seen_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "confirmed_at": { - "name": "confirmed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "ip_hash": { - "name": "ip_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "waitlist_signups_normalized_email_idx": { - "name": "waitlist_signups_normalized_email_idx", - "columns": [ - { - "expression": "normalized_email", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "waitlist_signups_referral_code_idx": { - "name": "waitlist_signups_referral_code_idx", - "columns": [ - { - "expression": "referral_code", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "waitlist_signups_status_idx": { - "name": "waitlist_signups_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "waitlist_signups_user_idx": { - "name": "waitlist_signups_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"waitlist_signups\".\"user_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "waitlist_signups_referred_by_idx": { - "name": "waitlist_signups_referred_by_idx", - "columns": [ - { - "expression": "referred_by", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "waitlist_signups_confirmed_idx": { - "name": "waitlist_signups_confirmed_idx", - "columns": [ - { - "expression": "confirmed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "waitlist_signups_user_id_users_id_fk": { - "name": "waitlist_signups_user_id_users_id_fk", - "tableFrom": "waitlist_signups", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "waitlist_signups_referred_by_waitlist_signups_id_fk": { - "name": "waitlist_signups_referred_by_waitlist_signups_id_fk", - "tableFrom": "waitlist_signups", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "referred_by" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.external_accounts": { - "name": "external_accounts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "service": { - "name": "service", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "issuer": { - "name": "issuer", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "app_id": { - "name": "app_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "external_user_id": { - "name": "external_user_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "external_accounts_scope_external_idx": { - "name": "external_accounts_scope_external_idx", - "columns": [ - { - "expression": "service", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "issuer", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "app_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "external_user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "external_accounts_user_scope_idx": { - "name": "external_accounts_user_scope_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "service", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "issuer", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "app_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "external_accounts_user_id_users_id_fk": { - "name": "external_accounts_user_id_users_id_fk", - "tableFrom": "external_accounts", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.identity_external_accounts": { - "name": "identity_external_accounts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "identity_id": { - "name": "identity_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "external_account_id": { - "name": "external_account_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "identity_external_accounts_binding_idx": { - "name": "identity_external_accounts_binding_idx", - "columns": [ - { - "expression": "identity_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "external_account_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "identity_external_accounts_account_idx": { - "name": "identity_external_accounts_account_idx", - "columns": [ - { - "expression": "external_account_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "identity_external_accounts_identity_id_auth_identities_id_fk": { - "name": "identity_external_accounts_identity_id_auth_identities_id_fk", - "tableFrom": "identity_external_accounts", - "tableTo": "auth_identities", - "columnsFrom": [ - "identity_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "identity_external_accounts_external_account_id_external_accounts_id_fk": { - "name": "identity_external_accounts_external_account_id_external_accounts_id_fk", - "tableFrom": "identity_external_accounts", - "tableTo": "external_accounts", - "columnsFrom": [ - "external_account_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.access_events": { - "name": "access_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "grant_id": { - "name": "grant_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "actor_admin_grant_id": { - "name": "actor_admin_grant_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "operation_id": { - "name": "operation_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "previous_status": { - "name": "previous_status", - "type": "access_grant_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": false - }, - "next_status": { - "name": "next_status", - "type": "access_grant_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "grant_version": { - "name": "grant_version", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "occurred_at": { - "name": "occurred_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "access_events_operation_grant_idx": { - "name": "access_events_operation_grant_idx", - "columns": [ - { - "expression": "operation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "grant_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "access_events_grant_version_idx": { - "name": "access_events_grant_version_idx", - "columns": [ - { - "expression": "grant_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "grant_version", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "access_events_grant_id_access_grants_id_fk": { - "name": "access_events_grant_id_access_grants_id_fk", - "tableFrom": "access_events", - "tableTo": "access_grants", - "columnsFrom": [ - "grant_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "access_events_actor_admin_grant_id_admin_role_grants_id_fk": { - "name": "access_events_actor_admin_grant_id_admin_role_grants_id_fk", - "tableFrom": "access_events", - "tableTo": "admin_role_grants", - "columnsFrom": [ - "actor_admin_grant_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "access_events_operation_id_access_operations_id_fk": { - "name": "access_events_operation_id_access_operations_id_fk", - "tableFrom": "access_events", - "tableTo": "access_operations", - "columnsFrom": [ - "operation_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "access_events_action_check": { - "name": "access_events_action_check", - "value": "\"access_events\".\"action\" in ('approve', 'revoke', 'activate', 'grandfather')" - }, - "access_events_version_check": { - "name": "access_events_version_check", - "value": "\"access_events\".\"grant_version\" > 0" - } - }, - "isRLSEnabled": false - }, - "public.access_grants": { - "name": "access_grants", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "access_grant_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "version": { - "name": "version", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "approved_at": { - "name": "approved_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revoked_at": { - "name": "revoked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "activated_at": { - "name": "activated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "access_grants_user_idx": { - "name": "access_grants_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"access_grants\".\"user_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "access_grants_signup_idx": { - "name": "access_grants_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"access_grants\".\"signup_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "access_grants_status_idx": { - "name": "access_grants_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "access_grants_user_id_users_id_fk": { - "name": "access_grants_user_id_users_id_fk", - "tableFrom": "access_grants", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "access_grants_signup_id_waitlist_signups_id_fk": { - "name": "access_grants_signup_id_waitlist_signups_id_fk", - "tableFrom": "access_grants", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "access_grants_target_check": { - "name": "access_grants_target_check", - "value": "\"access_grants\".\"user_id\" is not null or \"access_grants\".\"signup_id\" is not null" - }, - "access_grants_version_check": { - "name": "access_grants_version_check", - "value": "\"access_grants\".\"version\" > 0" - } - }, - "isRLSEnabled": false - }, - "public.access_operation_items": { - "name": "access_operation_items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "operation_id": { - "name": "operation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "outcome": { - "name": "outcome", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "code": { - "name": "code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "event_id": { - "name": "event_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "access_operation_items_operation_signup_idx": { - "name": "access_operation_items_operation_signup_idx", - "columns": [ - { - "expression": "operation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "access_operation_items_operation_id_access_operations_id_fk": { - "name": "access_operation_items_operation_id_access_operations_id_fk", - "tableFrom": "access_operation_items", - "tableTo": "access_operations", - "columnsFrom": [ - "operation_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "access_operation_items_signup_id_waitlist_signups_id_fk": { - "name": "access_operation_items_signup_id_waitlist_signups_id_fk", - "tableFrom": "access_operation_items", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - }, - "access_operation_items_event_id_access_events_id_fk": { - "name": "access_operation_items_event_id_access_events_id_fk", - "tableFrom": "access_operation_items", - "tableTo": "access_events", - "columnsFrom": [ - "event_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "access_operation_items_outcome_check": { - "name": "access_operation_items_outcome_check", - "value": "\"access_operation_items\".\"outcome\" in ('approved', 'revoked', 'unchanged', 'ineligible', 'failed')" - } - }, - "isRLSEnabled": false - }, - "public.access_operations": { - "name": "access_operations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "actor_admin_grant_id": { - "name": "actor_admin_grant_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "request_id": { - "name": "request_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "action": { - "name": "action", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "payload_hash": { - "name": "payload_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "access_operations_actor_request_idx": { - "name": "access_operations_actor_request_idx", - "columns": [ - { - "expression": "actor_admin_grant_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "request_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "access_operations_actor_admin_grant_id_admin_role_grants_id_fk": { - "name": "access_operations_actor_admin_grant_id_admin_role_grants_id_fk", - "tableFrom": "access_operations", - "tableTo": "admin_role_grants", - "columnsFrom": [ - "actor_admin_grant_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "access_operations_action_check": { - "name": "access_operations_action_check", - "value": "\"access_operations\".\"action\" in ('approve', 'revoke')" - } - }, - "isRLSEnabled": false - }, - "public.admin_role_grants": { - "name": "admin_role_grants", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'admin'" - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "granted_at": { - "name": "granted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "revoked_at": { - "name": "revoked_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "admin_role_grants_signup_role_idx": { - "name": "admin_role_grants_signup_role_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "role", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "admin_role_grants_signup_id_waitlist_signups_id_fk": { - "name": "admin_role_grants_signup_id_waitlist_signups_id_fk", - "tableFrom": "admin_role_grants", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "restrict", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "admin_role_grants_role_check": { - "name": "admin_role_grants_role_check", - "value": "\"admin_role_grants\".\"role\" = 'admin'" - } - }, - "isRLSEnabled": false - }, - "public.oauth_code_redemptions": { - "name": "oauth_code_redemptions", - "schema": "", - "columns": { - "code_hash": { - "name": "code_hash", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.email_subscriptions": { - "name": "email_subscriptions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "normalized_email": { - "name": "normalized_email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "purpose": { - "name": "purpose", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "email_subscription_status", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'unsubscribed'" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "signup_id": { - "name": "signup_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "email_subscriptions_address_purpose_idx": { - "name": "email_subscriptions_address_purpose_idx", - "columns": [ - { - "expression": "normalized_email", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "purpose", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "email_subscriptions_user_idx": { - "name": "email_subscriptions_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "email_subscriptions_signup_idx": { - "name": "email_subscriptions_signup_idx", - "columns": [ - { - "expression": "signup_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "email_subscriptions_user_id_users_id_fk": { - "name": "email_subscriptions_user_id_users_id_fk", - "tableFrom": "email_subscriptions", - "tableTo": "users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "email_subscriptions_signup_id_waitlist_signups_id_fk": { - "name": "email_subscriptions_signup_id_waitlist_signups_id_fk", - "tableFrom": "email_subscriptions", - "tableTo": "waitlist_signups", - "columnsFrom": [ - "signup_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": { - "public.user_status": { - "name": "user_status", - "schema": "public", - "values": [ - "active", - "disabled" - ] - }, - "public.account_role": { - "name": "account_role", - "schema": "public", - "values": [ - "member", - "admin" - ] - }, - "public.signup_status": { - "name": "signup_status", - "schema": "public", - "values": [ - "pending", - "confirmed", - "invited", - "unsubscribed", - "suppressed" - ] - }, - "public.access_grant_status": { - "name": "access_grant_status", - "schema": "public", - "values": [ - "approved", - "revoked" - ] - }, - "public.email_subscription_status": { - "name": "email_subscription_status", - "schema": "public", - "values": [ - "subscribed", - "unsubscribed" - ] - } - }, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 222773f3..f318d21a 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -40,30 +40,9 @@ { "idx": 5, "version": "7", - "when": 1788556660490, - "tag": "0005_canonical_user_foundation", - "breakpoints": true - }, - { - "idx": 6, - "version": "7", - "when": 1788559405884, - "tag": "0006_auth_identity_provider_metadata", - "breakpoints": true - }, - { - "idx": 7, - "version": "7", - "when": 1788564017686, - "tag": "0007_early_access_domains", - "breakpoints": true - }, - { - "idx": 8, - "version": "7", - "when": 1788565051000, - "tag": "0008_oauth_code_redemptions", + "when": 1788578400000, + "tag": "0005_early_access_foundation", "breakpoints": true } ] -} \ No newline at end of file +} diff --git a/lib/db/early-access-migration.integration.test.ts b/lib/db/early-access-migration.integration.test.ts index fe914385..0a0ce481 100644 --- a/lib/db/early-access-migration.integration.test.ts +++ b/lib/db/early-access-migration.integration.test.ts @@ -34,7 +34,7 @@ describe.skipIf(!databaseUrl)( await client?.end(); }); - it("upgrades production0004 through0008, preserving records and enforcing invariants", async () => { + it("upgrades production 0004 through squashed 0005, preserving records and enforcing invariants", async () => { const schema = `migration_${randomUUID().replaceAll("-", "")}`; const rollback = new Error("rollback_synthetic_migration_schema"); try { @@ -68,14 +68,11 @@ describe.skipIf(!databaseUrl)( VALUES (${conflict.id}, 'product_marketing', false, 'fixture', 'fixture'), (${confirmed.id}, 'product_marketing', true, 'fixture', 'fixture')`; await apply(5); - await apply(6); const [user] = await tx`INSERT INTO users DEFAULT VALUES RETURNING id`; const [identity] = await tx`INSERT INTO auth_identities (user_id, provider, provider_subject, external_user_id) VALUES (${user.id}, 'auth0', 'auth0|legacy-fixture', 'eu_original') RETURNING id`; - await apply(7); - await apply(8); await tx`INSERT INTO oauth_code_redemptions (code_hash, expires_at) VALUES ('synthetic-digest-only', now() + interval '1 minute')`; await expect( @@ -119,7 +116,7 @@ describe.skipIf(!databaseUrl)( const migration = readFileSync( path.resolve( process.cwd(), - "drizzle/0007_early_access_domains.sql" + "drizzle/0005_early_access_foundation.sql" ), "utf8" ); diff --git a/lib/db/early-access-migration.test.ts b/lib/db/early-access-migration.test.ts index fb3c130b..ffcbf193 100644 --- a/lib/db/early-access-migration.test.ts +++ b/lib/db/early-access-migration.test.ts @@ -20,7 +20,7 @@ import { } from "../../scripts/early-access/reconcile"; const sql = readFileSync( - resolve(process.cwd(), "drizzle/0007_early_access_domains.sql"), + resolve(process.cwd(), "drizzle/0005_early_access_foundation.sql"), "utf8" ); const issuer = "https://login.example"; @@ -212,13 +212,21 @@ describe("early-access migration and grandfather planning", () => { ); } ); - it("keeps journal history and appends domain and single-use code migrations", () => { + it("keeps waitlist journal history and squashes the unapplied tail into 0005", () => { const journal = JSON.parse( readFileSync(resolve(process.cwd(), "drizzle/meta/_journal.json"), "utf8") ); - expect(journal.entries.at(-2).tag).toBe("0007_early_access_domains"); - expect(journal.entries.at(-1).tag).toBe("0008_oauth_code_redemptions"); - expect(journal.entries).toHaveLength(9); + expect( + journal.entries.slice(0, 5).map((entry: { tag: string }) => entry.tag) + ).toEqual([ + "0000_dusty_krista_starr", + "0001_massive_vanisher", + "0002_empty_mach_iv", + "0003_consent_hardening", + "0004_curious_hellfire_club", + ]); + expect(journal.entries.at(-1).tag).toBe("0005_early_access_foundation"); + expect(journal.entries).toHaveLength(6); }); it("scopes identities/accounts and permits multiple accounts per user", () => { expect(authIdentities.externalUserId.notNull).toBe(false); diff --git a/scripts/early-access/README.md b/scripts/early-access/README.md index f59b2e65..c9bcdcdd 100644 --- a/scripts/early-access/README.md +++ b/scripts/early-access/README.md @@ -56,7 +56,7 @@ does not emit invitation emails or change subscriptions. ## Migration and permissions -Migration0007 is additive. It backfills admin grants and subscription snapshots, +`0005_early_access_foundation` is additive. It backfills admin grants and subscription snapshots, links historical consent records, and creates no product grants. Subscription rows with source `legacy_consent_conflict` require reconciliation before release; their state defaults to unsubscribed, while original evidence is preserved.