/ migrations / 0001_motionless_scarecrow.sql
0001_motionless_scarecrow.sql
1 CREATE TABLE "stripe_customer" ( 2 "id" serial PRIMARY KEY NOT NULL, 3 "user_id" integer NOT NULL, 4 "stripe_customer_id" text NOT NULL, 5 "created_at" timestamp with time zone DEFAULT now() NOT NULL, 6 "updated_at" timestamp with time zone DEFAULT now() NOT NULL, 7 CONSTRAINT "stripe_customer_user_id_unique" UNIQUE("user_id"), 8 CONSTRAINT "stripe_customer_stripe_customer_id_unique" UNIQUE("stripe_customer_id") 9 ); 10 --> statement-breakpoint 11 CREATE TABLE "stripe_subscription" ( 12 "id" serial PRIMARY KEY NOT NULL, 13 "stripe_customer_id" integer NOT NULL, 14 "stripe_subscription_id" text NOT NULL, 15 "stripe_price_id" text NOT NULL, 16 "status" text NOT NULL, 17 "current_period_start" timestamp with time zone NOT NULL, 18 "current_period_end" timestamp with time zone NOT NULL, 19 "cancel_at_period_end" boolean DEFAULT false NOT NULL, 20 "cancel_at" timestamp with time zone, 21 "canceled_at" timestamp with time zone, 22 "trial_start" timestamp with time zone, 23 "trial_end" timestamp with time zone, 24 "created_at" timestamp with time zone DEFAULT now() NOT NULL, 25 "updated_at" timestamp with time zone DEFAULT now() NOT NULL, 26 CONSTRAINT "stripe_subscription_stripe_subscription_id_unique" UNIQUE("stripe_subscription_id") 27 ); 28 --> statement-breakpoint 29 ALTER TABLE "stripe_customer" ADD CONSTRAINT "stripe_customer_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint 30 ALTER TABLE "stripe_subscription" ADD CONSTRAINT "stripe_subscription_stripe_customer_id_stripe_customer_id_fk" FOREIGN KEY ("stripe_customer_id") REFERENCES "public"."stripe_customer"("id") ON DELETE no action ON UPDATE no action;