CREATE TABLE "Payment" ( "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "Payment_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), "subscriptionId" integer NOT NULL, "stripePaymentIntentId" varchar(255), "amount" integer NOT NULL, "currency" varchar(3) DEFAULT 'gbp' NOT NULL, "status" varchar(32) NOT NULL, "createdAt" timestamp DEFAULT now() ); --> statement-breakpoint CREATE TABLE "Subscription" ( "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "Subscription_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), "userId" integer NOT NULL, "stripeCustomerId" varchar(255), "stripeSubscriptionId" varchar(255), "stripeSubscriptionItemId" varchar(255), "stripePriceId" varchar(255), "status" varchar(32) DEFAULT 'incomplete' NOT NULL, "currentPeriodStart" timestamp, "currentPeriodEnd" timestamp, "cancelAtPeriodEnd" boolean DEFAULT false NOT NULL, "trialEnd" timestamp, "quantity" integer DEFAULT 1 NOT NULL, "createdAt" timestamp DEFAULT now(), "updatedAt" timestamp DEFAULT now() ); --> statement-breakpoint ALTER TABLE "User" ADD COLUMN "plan" varchar(32) DEFAULT 'free' NOT NULL;--> statement-breakpoint ALTER TABLE "Payment" ADD CONSTRAINT "Payment_subscriptionId_Subscription_id_fk" FOREIGN KEY ("subscriptionId") REFERENCES "public"."Subscription"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE "Subscription" ADD CONSTRAINT "Subscription_userId_User_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."User"("id") ON DELETE no action ON UPDATE no action;