0006_safe_risque.sql16 lines · main
| 1 | CREATE TABLE "subscriptions" ( |
| 2 | "id" text PRIMARY KEY NOT NULL, |
| 3 | "owner_id" text NOT NULL, |
| 4 | "polar_subscription_id" text, |
| 5 | "polar_customer_id" text, |
| 6 | "tier" text DEFAULT 'free' NOT NULL, |
| 7 | "status" text DEFAULT 'active' NOT NULL, |
| 8 | "current_period_end" timestamp with time zone, |
| 9 | "canceled_at" timestamp with time zone, |
| 10 | "created_at" timestamp with time zone DEFAULT now() NOT NULL, |
| 11 | "updated_at" timestamp with time zone DEFAULT now() NOT NULL |
| 12 | ); |
| 13 | --> statement-breakpoint |
| 14 | ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_owner_id_users_id_fk" FOREIGN KEY ("owner_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint |
| 15 | CREATE UNIQUE INDEX "subscriptions_owner_idx" ON "subscriptions" USING btree ("owner_id");--> statement-breakpoint |
| 16 | CREATE INDEX "subscriptions_polar_idx" ON "subscriptions" USING btree ("polar_subscription_id"); |