CREATE TABLE "account" ( "userId" text NOT NULL, "type" text NOT NULL, "provider" text NOT NULL, "providerAccountId" text NOT NULL, "refresh_token" text, "access_token" text, "expires_at" integer, "token_type" text, "scope" text, "id_token" text, "session_state" text, CONSTRAINT "account_provider_providerAccountId_pk" PRIMARY KEY("provider","providerAccountId") ); --> statement-breakpoint CREATE TABLE "session" ( "sessionToken" text PRIMARY KEY NOT NULL, "userId" text NOT NULL, "expires" timestamp NOT NULL ); --> statement-breakpoint CREATE TABLE "user" ( "id" text PRIMARY KEY NOT NULL, "name" text, "email" text NOT NULL, "emailVerified" timestamp, "image" text ); --> statement-breakpoint CREATE TABLE "verificationToken" ( "identifier" text NOT NULL, "token" text NOT NULL, "expires" timestamp NOT NULL, CONSTRAINT "verificationToken_identifier_token_pk" PRIMARY KEY("identifier","token") ); --> statement-breakpoint CREATE TABLE "policy_settings" ( "id" text PRIMARY KEY NOT NULL, "tenant_id" text NOT NULL, "policy_name" text NOT NULL, "policy_type" text NOT NULL, "setting_name" text NOT NULL, "setting_value" text NOT NULL, "graph_policy_id" text NOT NULL, "last_synced_at" timestamp DEFAULT now() NOT NULL, "created_at" timestamp DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "subscriptions" ( "user_id" varchar(255), "stripe_customer_id" varchar(255), "stripe_subscription_id" varchar(255), "stripe_price_id" varchar(255), "stripe_current_period_end" timestamp, CONSTRAINT "subscriptions_user_id_stripe_customer_id_pk" PRIMARY KEY("user_id","stripe_customer_id"), CONSTRAINT "subscriptions_user_id_unique" UNIQUE("user_id"), CONSTRAINT "subscriptions_stripe_customer_id_unique" UNIQUE("stripe_customer_id"), CONSTRAINT "subscriptions_stripe_subscription_id_unique" UNIQUE("stripe_subscription_id") ); --> statement-breakpoint ALTER TABLE "account" ADD CONSTRAINT "account_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "session" ADD CONSTRAINT "session_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint CREATE INDEX "policy_settings_tenant_id_idx" ON "policy_settings" USING btree ("tenant_id");--> statement-breakpoint CREATE INDEX "policy_settings_setting_name_idx" ON "policy_settings" USING btree ("setting_name");--> statement-breakpoint CREATE INDEX "policy_settings_upsert_idx" ON "policy_settings" USING btree ("tenant_id","graph_policy_id","setting_name");