aboutsummaryrefslogtreecommitdiff
path: root/apps/web/migrations/000_setup.sql
diff options
context:
space:
mode:
authorKinfe Michael Tariku <[email protected]>2024-06-25 19:56:54 +0300
committerGitHub <[email protected]>2024-06-25 19:56:54 +0300
commitf46e42c2dfd1b223d4ad701a86d05fc0bb380e45 (patch)
treef17fdfadf3bec08eee7f02da33af952796657254 /apps/web/migrations/000_setup.sql
parentfix: import using absolute path (diff)
parentdev and prod databases (diff)
downloadsupermemory-f46e42c2dfd1b223d4ad701a86d05fc0bb380e45.tar.xz
supermemory-f46e42c2dfd1b223d4ad701a86d05fc0bb380e45.zip
Merge branch 'main' into feat/landing_revamp
Diffstat (limited to 'apps/web/migrations/000_setup.sql')
-rw-r--r--apps/web/migrations/000_setup.sql74
1 files changed, 51 insertions, 23 deletions
diff --git a/apps/web/migrations/000_setup.sql b/apps/web/migrations/000_setup.sql
index 8a076f73..a4855ec9 100644
--- a/apps/web/migrations/000_setup.sql
+++ b/apps/web/migrations/000_setup.sql
@@ -1,18 +1,46 @@
CREATE TABLE `account` (
- `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
- `userId` text(255) NOT NULL,
- `type` text(255) NOT NULL,
- `provider` text(255) NOT NULL,
- `providerAccountId` text(255) NOT NULL,
+ `userId` text NOT NULL,
+ `type` text NOT NULL,
+ `provider` text NOT NULL,
+ `providerAccountId` text NOT NULL,
`refresh_token` text,
`access_token` text,
`expires_at` integer,
- `token_type` text(255),
- `scope` text(255),
+ `token_type` text,
+ `scope` text,
`id_token` text,
- `session_state` text(255),
- `oauth_token_secret` text,
- `oauth_token` text,
+ `session_state` text,
+ PRIMARY KEY(`provider`, `providerAccountId`),
+ FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
+);
+--> statement-breakpoint
+CREATE TABLE `authenticator` (
+ `credentialID` text NOT NULL,
+ `userId` text NOT NULL,
+ `providerAccountId` text NOT NULL,
+ `credentialPublicKey` text NOT NULL,
+ `counter` integer NOT NULL,
+ `credentialDeviceType` text NOT NULL,
+ `credentialBackedUp` integer NOT NULL,
+ `transports` text,
+ PRIMARY KEY(`credentialID`, `userId`),
+ FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
+);
+--> statement-breakpoint
+CREATE TABLE `chatHistory` (
+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
+ `threadId` text NOT NULL,
+ `question` text NOT NULL,
+ `answerParts` text,
+ `answerSources` text,
+ `answerJustification` text,
+ FOREIGN KEY (`threadId`) REFERENCES `chatThread`(`id`) ON UPDATE no action ON DELETE cascade
+);
+--> statement-breakpoint
+CREATE TABLE `chatThread` (
+ `id` text PRIMARY KEY NOT NULL,
+ `firstMessage` text NOT NULL,
+ `userId` text NOT NULL,
FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
@@ -25,9 +53,8 @@ CREATE TABLE `contentToSpace` (
);
--> statement-breakpoint
CREATE TABLE `session` (
- `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
- `sessionToken` text(255) NOT NULL,
- `userId` text(255) NOT NULL,
+ `sessionToken` text PRIMARY KEY NOT NULL,
+ `userId` text NOT NULL,
`expires` integer NOT NULL,
FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
);
@@ -50,27 +77,28 @@ CREATE TABLE `storedContent` (
`ogImage` text(255),
`type` text DEFAULT 'page',
`image` text(255),
- `user` text(255),
+ `user` text,
FOREIGN KEY (`user`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `user` (
- `id` text(255) PRIMARY KEY NOT NULL,
- `name` text(255),
- `email` text(255) NOT NULL,
- `emailVerified` integer DEFAULT CURRENT_TIMESTAMP,
- `image` text(255)
+ `id` text PRIMARY KEY NOT NULL,
+ `name` text,
+ `email` text NOT NULL,
+ `emailVerified` integer,
+ `image` text
);
--> statement-breakpoint
CREATE TABLE `verificationToken` (
- `identifier` text(255) NOT NULL,
- `token` text(255) NOT NULL,
+ `identifier` text NOT NULL,
+ `token` text NOT NULL,
`expires` integer NOT NULL,
PRIMARY KEY(`identifier`, `token`)
);
--> statement-breakpoint
-CREATE INDEX `account_userId_idx` ON `account` (`userId`);--> statement-breakpoint
-CREATE INDEX `session_userId_idx` ON `session` (`userId`);--> statement-breakpoint
+CREATE UNIQUE INDEX `authenticator_credentialID_unique` ON `authenticator` (`credentialID`);--> statement-breakpoint
+CREATE INDEX `chatHistory_thread_idx` ON `chatHistory` (`threadId`);--> statement-breakpoint
+CREATE INDEX `chatThread_user_idx` ON `chatThread` (`userId`);--> statement-breakpoint
CREATE UNIQUE INDEX `space_name_unique` ON `space` (`name`);--> statement-breakpoint
CREATE INDEX `spaces_name_idx` ON `space` (`name`);--> statement-breakpoint
CREATE INDEX `spaces_user_idx` ON `space` (`user`);--> statement-breakpoint