Files
Sauci/apps/api/drizzle/0000_identity_and_feature_interests.sql
jjbrunton 006761d3b0 feat(backend): add standalone data plane
Replace the Supabase application data plane with the Node/PostgreSQL API, migrate mobile, admin, web, and MCP callers, add controlled cutover tooling, and define hardened Dokploy infrastructure.
2026-08-28 14:42:11 +01:00

36 lines
1.6 KiB
SQL

CREATE TABLE "profiles" (
"id" uuid PRIMARY KEY NOT NULL,
"name" text,
"email" text,
"avatar_url" text,
"push_token" text,
"is_premium" boolean DEFAULT false NOT NULL,
"couple_id" uuid,
"gender" text,
"show_explicit_content" boolean DEFAULT true NOT NULL,
"max_intensity" integer DEFAULT 5 NOT NULL,
"public_key_jwk" jsonb,
"hide_nsfw" boolean DEFAULT false NOT NULL,
"onboarding_completed" boolean DEFAULT false NOT NULL,
"onboarding_version" integer DEFAULT 0 NOT NULL,
"auth_synced_at" timestamp with time zone DEFAULT now() NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "profiles_gender_check" CHECK ("gender" IS NULL OR "gender" IN ('male', 'female', 'non-binary', 'prefer-not-to-say')),
CONSTRAINT "profiles_max_intensity_check" CHECK ("max_intensity" BETWEEN 1 AND 5)
);
--> statement-breakpoint
CREATE INDEX "profiles_couple_id_idx" ON "profiles" USING btree ("couple_id");
--> statement-breakpoint
CREATE TABLE "feature_interests" (
"user_id" uuid NOT NULL,
"feature" text NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "feature_interests_user_id_feature_pk" PRIMARY KEY("user_id", "feature")
);
--> statement-breakpoint
ALTER TABLE "feature_interests" ADD CONSTRAINT "feature_interests_user_id_profiles_id_fk"
FOREIGN KEY ("user_id") REFERENCES "profiles"("id") ON DELETE cascade;
--> statement-breakpoint
CREATE INDEX "feature_interests_feature_idx" ON "feature_interests" USING btree ("feature");