aboutsummaryrefslogtreecommitdiffstats
path: root/packages/db/drizzle/0058_add_subscription.sql
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2025-07-13 09:28:24 +0000
committerMohamed Bassem <me@mbassem.com>2025-07-13 20:44:00 +0000
commitd1d5263486f96db578aad918a59007045c3c077f (patch)
treedf65f062b6eda93364f7d509fc2c52663561097a /packages/db/drizzle/0058_add_subscription.sql
parent845ccf1ad46c8635782f8e10280b07c48c08eaf5 (diff)
downloadkarakeep-d1d5263486f96db578aad918a59007045c3c077f.tar.zst
feat: Add stripe based subscriptions
Diffstat (limited to 'packages/db/drizzle/0058_add_subscription.sql')
-rw-r--r--packages/db/drizzle/0058_add_subscription.sql19
1 files changed, 19 insertions, 0 deletions
diff --git a/packages/db/drizzle/0058_add_subscription.sql b/packages/db/drizzle/0058_add_subscription.sql
new file mode 100644
index 00000000..77260c58
--- /dev/null
+++ b/packages/db/drizzle/0058_add_subscription.sql
@@ -0,0 +1,19 @@
+CREATE TABLE `subscriptions` (
+ `id` text PRIMARY KEY NOT NULL,
+ `userId` text NOT NULL,
+ `stripeCustomerId` text NOT NULL,
+ `stripeSubscriptionId` text,
+ `status` text NOT NULL,
+ `tier` text DEFAULT 'free' NOT NULL,
+ `priceId` text,
+ `cancelAtPeriodEnd` integer DEFAULT false,
+ `startDate` integer,
+ `endDate` integer,
+ `createdAt` integer NOT NULL,
+ `modifiedAt` integer,
+ FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
+);
+--> statement-breakpoint
+CREATE UNIQUE INDEX `subscriptions_userId_unique` ON `subscriptions` (`userId`);--> statement-breakpoint
+CREATE INDEX `subscriptions_userId_idx` ON `subscriptions` (`userId`);--> statement-breakpoint
+CREATE INDEX `subscriptions_stripeCustomerId_idx` ON `subscriptions` (`stripeCustomerId`); \ No newline at end of file