feat: prompt user to create subscription if inactive

This commit is contained in:
Henry
2025-09-02 13:12:43 +01:00
parent a7c68db90e
commit 5f4678ab4e
9 changed files with 162 additions and 38 deletions

View File

@@ -1,7 +1,7 @@
CREATE TABLE IF NOT EXISTS "subscription" (
"id" bigserial PRIMARY KEY NOT NULL,
"plan" varchar(255) NOT NULL,
"referenceId" uuid,
"referenceId" varchar(12) NOT NULL,
"stripeCustomerId" varchar(255),
"stripeSubscriptionId" varchar(255),
"status" varchar(255) NOT NULL,
@@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS "subscription" (
--> statement-breakpoint
ALTER TABLE "subscription" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "subscription" ADD CONSTRAINT "subscription_referenceId_user_id_fk" FOREIGN KEY ("referenceId") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;
ALTER TABLE "subscription" ADD CONSTRAINT "subscription_referenceId_workspace_publicId_fk" FOREIGN KEY ("referenceId") REFERENCES "public"."workspace"("publicId") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;

View File

@@ -1,5 +1,5 @@
{
"id": "35e9d75a-9dad-4f25-8471-a94132fa12e1",
"id": "d16ab16a-b4af-4d34-abb9-e663f4e63307",
"prevId": "5d713202-07aa-46e3-abc2-83d0eb6d0858",
"version": "7",
"dialect": "postgresql",
@@ -2339,9 +2339,9 @@
},
"referenceId": {
"name": "referenceId",
"type": "uuid",
"type": "varchar(12)",
"primaryKey": false,
"notNull": false
"notNull": true
},
"stripeCustomerId": {
"name": "stripeCustomerId",
@@ -2414,17 +2414,17 @@
},
"indexes": {},
"foreignKeys": {
"subscription_referenceId_user_id_fk": {
"name": "subscription_referenceId_user_id_fk",
"subscription_referenceId_workspace_publicId_fk": {
"name": "subscription_referenceId_workspace_publicId_fk",
"tableFrom": "subscription",
"tableTo": "user",
"tableTo": "workspace",
"columnsFrom": [
"referenceId"
],
"columnsTo": [
"id"
"publicId"
],
"onDelete": "set null",
"onDelete": "no action",
"onUpdate": "no action"
}
},

View File

@@ -68,8 +68,8 @@
{
"idx": 9,
"version": "7",
"when": 1756757589852,
"tag": "20250901201309_concerned_doctor_octopus",
"when": 1756803246096,
"tag": "20250902085406_AddSubscriptions",
"breakpoints": true
}
]