From 9f0fb14d56fcbd9280aee2bdd83d55e8fabbe7d2 Mon Sep 17 00:00:00 2001
From: Dhravya <dhravyashah@gmail.com>
Date: Fri, 14 Jun 2024 23:35:19 -0500
Subject: [MIGRATION REQUIRED]Data fetchers and other server actions, spaces
 creation and database migrations

---
 apps/web/migrations/000_setup.sql | 55 +++++++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 23 deletions(-)

(limited to 'apps/web/migrations/000_setup.sql')

diff --git a/apps/web/migrations/000_setup.sql b/apps/web/migrations/000_setup.sql
index db7f9444..0c151b98 100644
--- a/apps/web/migrations/000_setup.sql
+++ b/apps/web/migrations/000_setup.sql
@@ -1,18 +1,29 @@
 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
@@ -25,9 +36,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 +60,26 @@ CREATE TABLE `storedContent` (
 	`ogImage` text(255),
 	`type` text DEFAULT 'page',
 	`image` text(255),
-	`user` text(255),
+	`user` integer,
 	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 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
-- 
cgit v1.2.3

