aboutsummaryrefslogtreecommitdiffstats
path: root/packages/db/drizzle/0058_add_subscription.sql
blob: 77260c585e091a9038438b6e16c3f2c3cbcde9a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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`);