aboutsummaryrefslogtreecommitdiffstats
path: root/web/prisma
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-02-06 12:26:29 +0000
committerMohamedBassem <me@mbassem.com>2024-02-06 12:26:29 +0000
commit083ea5bd19172381bb53e95aaf98eaabef839c54 (patch)
tree4d1c041aab7cd8d15382330db08caeb9c5a12c63 /web/prisma
parentb792121977ade8bdd3fb62704b65a9fcbd1436b9 (diff)
downloadkarakeep-083ea5bd19172381bb53e95aaf98eaabef839c54.tar.zst
Move the web app into a subdir
Diffstat (limited to 'web/prisma')
-rw-r--r--web/prisma/migrations/20240205153748_add_users/migration.sql56
-rw-r--r--web/prisma/migrations/20240206000813_add_links/migration.sql43
-rw-r--r--web/prisma/migrations/migration_lock.toml3
-rw-r--r--web/prisma/schema.prisma105
4 files changed, 207 insertions, 0 deletions
diff --git a/web/prisma/migrations/20240205153748_add_users/migration.sql b/web/prisma/migrations/20240205153748_add_users/migration.sql
new file mode 100644
index 00000000..cbf47073
--- /dev/null
+++ b/web/prisma/migrations/20240205153748_add_users/migration.sql
@@ -0,0 +1,56 @@
+-- CreateTable
+CREATE TABLE "Account" (
+ "id" TEXT NOT NULL PRIMARY KEY,
+ "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,
+ "scope" TEXT,
+ "id_token" TEXT,
+ "session_state" TEXT,
+ CONSTRAINT "Account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+-- CreateTable
+CREATE TABLE "Session" (
+ "id" TEXT NOT NULL PRIMARY KEY,
+ "sessionToken" TEXT NOT NULL,
+ "userId" TEXT NOT NULL,
+ "expires" DATETIME NOT NULL,
+ CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+-- CreateTable
+CREATE TABLE "User" (
+ "id" TEXT NOT NULL PRIMARY KEY,
+ "name" TEXT,
+ "email" TEXT,
+ "emailVerified" DATETIME,
+ "image" TEXT
+);
+
+-- CreateTable
+CREATE TABLE "VerificationToken" (
+ "identifier" TEXT NOT NULL,
+ "token" TEXT NOT NULL,
+ "expires" DATETIME NOT NULL
+);
+
+-- CreateIndex
+CREATE UNIQUE INDEX "Account_provider_providerAccountId_key" ON "Account"("provider", "providerAccountId");
+
+-- CreateIndex
+CREATE UNIQUE INDEX "Session_sessionToken_key" ON "Session"("sessionToken");
+
+-- CreateIndex
+CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
+
+-- CreateIndex
+CREATE UNIQUE INDEX "VerificationToken_token_key" ON "VerificationToken"("token");
+
+-- CreateIndex
+CREATE UNIQUE INDEX "VerificationToken_identifier_token_key" ON "VerificationToken"("identifier", "token");
diff --git a/web/prisma/migrations/20240206000813_add_links/migration.sql b/web/prisma/migrations/20240206000813_add_links/migration.sql
new file mode 100644
index 00000000..38c8d938
--- /dev/null
+++ b/web/prisma/migrations/20240206000813_add_links/migration.sql
@@ -0,0 +1,43 @@
+-- CreateTable
+CREATE TABLE "BookmarkedLink" (
+ "id" TEXT NOT NULL PRIMARY KEY,
+ "url" TEXT NOT NULL,
+ "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "userId" TEXT NOT NULL,
+ CONSTRAINT "BookmarkedLink_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+-- CreateTable
+CREATE TABLE "BookmarkedLinkDetails" (
+ "id" TEXT NOT NULL PRIMARY KEY,
+ "title" TEXT NOT NULL,
+ "description" TEXT NOT NULL,
+ "imageUrl" TEXT NOT NULL,
+ "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ CONSTRAINT "BookmarkedLinkDetails_id_fkey" FOREIGN KEY ("id") REFERENCES "BookmarkedLink" ("id") ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+-- CreateTable
+CREATE TABLE "BookmarkTags" (
+ "id" TEXT NOT NULL PRIMARY KEY,
+ "name" TEXT NOT NULL,
+ "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "userId" TEXT NOT NULL,
+ CONSTRAINT "BookmarkTags_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+-- CreateTable
+CREATE TABLE "TagsOnLinks" (
+ "linkId" TEXT NOT NULL,
+ "tagId" TEXT NOT NULL,
+ "attachedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "bookmarkTagsId" TEXT NOT NULL,
+ CONSTRAINT "TagsOnLinks_linkId_fkey" FOREIGN KEY ("linkId") REFERENCES "BookmarkedLink" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "TagsOnLinks_tagId_fkey" FOREIGN KEY ("tagId") REFERENCES "BookmarkTags" ("id") ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+-- CreateIndex
+CREATE UNIQUE INDEX "BookmarkTags_name_key" ON "BookmarkTags"("name");
+
+-- CreateIndex
+CREATE UNIQUE INDEX "TagsOnLinks_linkId_tagId_key" ON "TagsOnLinks"("linkId", "tagId");
diff --git a/web/prisma/migrations/migration_lock.toml b/web/prisma/migrations/migration_lock.toml
new file mode 100644
index 00000000..e5e5c470
--- /dev/null
+++ b/web/prisma/migrations/migration_lock.toml
@@ -0,0 +1,3 @@
+# Please do not edit this file manually
+# It should be added in your version-control system (i.e. Git)
+provider = "sqlite" \ No newline at end of file
diff --git a/web/prisma/schema.prisma b/web/prisma/schema.prisma
new file mode 100644
index 00000000..54be3eae
--- /dev/null
+++ b/web/prisma/schema.prisma
@@ -0,0 +1,105 @@
+// This is your Prisma schema file,
+// learn more about it in the docs: https://pris.ly/d/prisma-schema
+
+generator client {
+ provider = "prisma-client-js"
+}
+
+datasource db {
+ provider = "sqlite"
+ url = env("DATABASE_URL")
+}
+
+model Account {
+ id String @id @default(cuid())
+ userId String
+ type String
+ provider String
+ providerAccountId String
+ refresh_token String?
+ access_token String?
+ expires_at Int?
+ token_type String?
+ scope String?
+ id_token String?
+ session_state String?
+
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
+
+ @@unique([provider, providerAccountId])
+}
+
+model Session {
+ id String @id @default(cuid())
+ sessionToken String @unique
+ userId String
+ expires DateTime
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
+}
+
+model User {
+ id String @id @default(cuid())
+ name String?
+ email String? @unique
+ emailVerified DateTime?
+ image String?
+ accounts Account[]
+ sessions Session[]
+ links BookmarkedLink[]
+ tags BookmarkTags[]
+}
+
+model VerificationToken {
+ identifier String
+ token String @unique
+ expires DateTime
+
+ @@unique([identifier, token])
+}
+
+model BookmarkedLink {
+ id String @id @default(cuid())
+ url String
+ createdAt DateTime @default(now())
+
+ userId String
+
+ details BookmarkedLinkDetails?
+
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
+ tags TagsOnLinks[]
+}
+
+model BookmarkedLinkDetails {
+ id String @id
+ title String
+ description String
+ imageUrl String
+ createdAt DateTime @default(now())
+
+ link BookmarkedLink @relation(fields: [id], references: [id], onDelete: Cascade)
+}
+
+model BookmarkTags {
+ id String @id @default(cuid())
+ name String @unique
+ createdAt DateTime @default(now())
+
+ userId String
+
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
+ attachedLinks TagsOnLinks[]
+}
+
+model TagsOnLinks {
+ link BookmarkedLink @relation(fields: [linkId], references: [id], onDelete: Cascade)
+ linkId String
+
+ tag BookmarkTags @relation(fields: [tagId], references: [id], onDelete: Cascade)
+ tagId String
+
+ attachedAt DateTime @default(now())
+ bookmarkTagsId String
+
+ @@unique([linkId, tagId])
+}