aboutsummaryrefslogtreecommitdiffstats
path: root/packages/db/prisma
diff options
context:
space:
mode:
Diffstat (limited to 'packages/db/prisma')
-rw-r--r--packages/db/prisma/migrations/20240205153748_add_users/migration.sql56
-rw-r--r--packages/db/prisma/migrations/20240206000813_add_links/migration.sql43
-rw-r--r--packages/db/prisma/migrations/20240206192241_add_favicon/migration.sql16
-rw-r--r--packages/db/prisma/migrations/20240207204211_drop_extra_field_in_tags_links/migration.sql21
-rw-r--r--packages/db/prisma/migrations/20240209013653_toplevel_bookmark/migration.sql62
-rw-r--r--packages/db/prisma/migrations/20240211184744_add_api_key/migration.sql16
-rw-r--r--packages/db/prisma/migrations/20240214011350_fix_tag_name_index/migration.sql11
-rw-r--r--packages/db/prisma/migrations/20240221104430_add_password_support/migration.sql2
-rw-r--r--packages/db/prisma/migrations/20240222152033_name_and_email_required/migration.sql23
-rw-r--r--packages/db/prisma/migrations/migration_lock.toml3
-rw-r--r--packages/db/prisma/schema.prisma129
11 files changed, 0 insertions, 382 deletions
diff --git a/packages/db/prisma/migrations/20240205153748_add_users/migration.sql b/packages/db/prisma/migrations/20240205153748_add_users/migration.sql
deleted file mode 100644
index cbf47073..00000000
--- a/packages/db/prisma/migrations/20240205153748_add_users/migration.sql
+++ /dev/null
@@ -1,56 +0,0 @@
--- 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/packages/db/prisma/migrations/20240206000813_add_links/migration.sql b/packages/db/prisma/migrations/20240206000813_add_links/migration.sql
deleted file mode 100644
index 38c8d938..00000000
--- a/packages/db/prisma/migrations/20240206000813_add_links/migration.sql
+++ /dev/null
@@ -1,43 +0,0 @@
--- 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/packages/db/prisma/migrations/20240206192241_add_favicon/migration.sql b/packages/db/prisma/migrations/20240206192241_add_favicon/migration.sql
deleted file mode 100644
index 330575e9..00000000
--- a/packages/db/prisma/migrations/20240206192241_add_favicon/migration.sql
+++ /dev/null
@@ -1,16 +0,0 @@
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_BookmarkedLinkDetails" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "title" TEXT,
- "description" TEXT,
- "imageUrl" TEXT,
- "favicon" TEXT,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- CONSTRAINT "BookmarkedLinkDetails_id_fkey" FOREIGN KEY ("id") REFERENCES "BookmarkedLink" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-INSERT INTO "new_BookmarkedLinkDetails" ("createdAt", "description", "id", "imageUrl", "title") SELECT "createdAt", "description", "id", "imageUrl", "title" FROM "BookmarkedLinkDetails";
-DROP TABLE "BookmarkedLinkDetails";
-ALTER TABLE "new_BookmarkedLinkDetails" RENAME TO "BookmarkedLinkDetails";
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
diff --git a/packages/db/prisma/migrations/20240207204211_drop_extra_field_in_tags_links/migration.sql b/packages/db/prisma/migrations/20240207204211_drop_extra_field_in_tags_links/migration.sql
deleted file mode 100644
index 78184041..00000000
--- a/packages/db/prisma/migrations/20240207204211_drop_extra_field_in_tags_links/migration.sql
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `bookmarkTagsId` on the `TagsOnLinks` table. All the data in the column will be lost.
-
-*/
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_TagsOnLinks" (
- "linkId" TEXT NOT NULL,
- "tagId" TEXT NOT NULL,
- "attachedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- 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
-);
-INSERT INTO "new_TagsOnLinks" ("attachedAt", "linkId", "tagId") SELECT "attachedAt", "linkId", "tagId" FROM "TagsOnLinks";
-DROP TABLE "TagsOnLinks";
-ALTER TABLE "new_TagsOnLinks" RENAME TO "TagsOnLinks";
-CREATE UNIQUE INDEX "TagsOnLinks_linkId_tagId_key" ON "TagsOnLinks"("linkId", "tagId");
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
diff --git a/packages/db/prisma/migrations/20240209013653_toplevel_bookmark/migration.sql b/packages/db/prisma/migrations/20240209013653_toplevel_bookmark/migration.sql
deleted file mode 100644
index 2b5aa370..00000000
--- a/packages/db/prisma/migrations/20240209013653_toplevel_bookmark/migration.sql
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the `BookmarkedLinkDetails` table. If the table is not empty, all the data it contains will be lost.
- - You are about to drop the `TagsOnLinks` table. If the table is not empty, all the data it contains will be lost.
- - You are about to drop the column `createdAt` on the `BookmarkedLink` table. All the data in the column will be lost.
- - You are about to drop the column `userId` on the `BookmarkedLink` table. All the data in the column will be lost.
-
-*/
--- DropIndex
-DROP INDEX "TagsOnLinks_linkId_tagId_key";
-
--- DropTable
-PRAGMA foreign_keys=off;
-DROP TABLE "BookmarkedLinkDetails";
-PRAGMA foreign_keys=on;
-
--- DropTable
-PRAGMA foreign_keys=off;
-DROP TABLE "TagsOnLinks";
-PRAGMA foreign_keys=on;
-
--- CreateTable
-CREATE TABLE "Bookmark" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "archived" BOOLEAN NOT NULL DEFAULT false,
- "favourited" BOOLEAN NOT NULL DEFAULT false,
- "userId" TEXT NOT NULL,
- CONSTRAINT "Bookmark_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "TagsOnBookmarks" (
- "bookmarkId" TEXT NOT NULL,
- "tagId" TEXT NOT NULL,
- "attachedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "attachedBy" TEXT NOT NULL,
- CONSTRAINT "TagsOnBookmarks_bookmarkId_fkey" FOREIGN KEY ("bookmarkId") REFERENCES "Bookmark" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "TagsOnBookmarks_tagId_fkey" FOREIGN KEY ("tagId") REFERENCES "BookmarkTags" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_BookmarkedLink" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "url" TEXT NOT NULL,
- "title" TEXT,
- "description" TEXT,
- "imageUrl" TEXT,
- "favicon" TEXT,
- "crawledAt" DATETIME,
- CONSTRAINT "BookmarkedLink_id_fkey" FOREIGN KEY ("id") REFERENCES "Bookmark" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-INSERT INTO "new_BookmarkedLink" ("id", "url") SELECT "id", "url" FROM "BookmarkedLink";
-DROP TABLE "BookmarkedLink";
-ALTER TABLE "new_BookmarkedLink" RENAME TO "BookmarkedLink";
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
-
--- CreateIndex
-CREATE UNIQUE INDEX "TagsOnBookmarks_bookmarkId_tagId_key" ON "TagsOnBookmarks"("bookmarkId", "tagId");
diff --git a/packages/db/prisma/migrations/20240211184744_add_api_key/migration.sql b/packages/db/prisma/migrations/20240211184744_add_api_key/migration.sql
deleted file mode 100644
index c39bf511..00000000
--- a/packages/db/prisma/migrations/20240211184744_add_api_key/migration.sql
+++ /dev/null
@@ -1,16 +0,0 @@
--- CreateTable
-CREATE TABLE "ApiKey" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "name" TEXT NOT NULL,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "keyId" TEXT NOT NULL,
- "keyHash" TEXT NOT NULL,
- "userId" TEXT NOT NULL,
- CONSTRAINT "ApiKey_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateIndex
-CREATE UNIQUE INDEX "ApiKey_keyId_key" ON "ApiKey"("keyId");
-
--- CreateIndex
-CREATE UNIQUE INDEX "ApiKey_name_userId_key" ON "ApiKey"("name", "userId");
diff --git a/packages/db/prisma/migrations/20240214011350_fix_tag_name_index/migration.sql b/packages/db/prisma/migrations/20240214011350_fix_tag_name_index/migration.sql
deleted file mode 100644
index cbcd8821..00000000
--- a/packages/db/prisma/migrations/20240214011350_fix_tag_name_index/migration.sql
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- Warnings:
-
- - A unique constraint covering the columns `[userId,name]` on the table `BookmarkTags` will be added. If there are existing duplicate values, this will fail.
-
-*/
--- DropIndex
-DROP INDEX "BookmarkTags_name_key";
-
--- CreateIndex
-CREATE UNIQUE INDEX "BookmarkTags_userId_name_key" ON "BookmarkTags"("userId", "name");
diff --git a/packages/db/prisma/migrations/20240221104430_add_password_support/migration.sql b/packages/db/prisma/migrations/20240221104430_add_password_support/migration.sql
deleted file mode 100644
index 4c9b7b00..00000000
--- a/packages/db/prisma/migrations/20240221104430_add_password_support/migration.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- AlterTable
-ALTER TABLE "User" ADD COLUMN "password" TEXT;
diff --git a/packages/db/prisma/migrations/20240222152033_name_and_email_required/migration.sql b/packages/db/prisma/migrations/20240222152033_name_and_email_required/migration.sql
deleted file mode 100644
index fa73b56e..00000000
--- a/packages/db/prisma/migrations/20240222152033_name_and_email_required/migration.sql
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- Warnings:
-
- - Made the column `email` on table `User` required. This step will fail if there are existing NULL values in that column.
- - Made the column `name` on table `User` required. This step will fail if there are existing NULL values in that column.
-
-*/
--- RedefineTables
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_User" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "name" TEXT NOT NULL,
- "email" TEXT NOT NULL,
- "emailVerified" DATETIME,
- "password" TEXT,
- "image" TEXT
-);
-INSERT INTO "new_User" ("email", "emailVerified", "id", "image", "name", "password") SELECT "email", "emailVerified", "id", "image", "name", "password" FROM "User";
-DROP TABLE "User";
-ALTER TABLE "new_User" RENAME TO "User";
-CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
-PRAGMA foreign_key_check;
-PRAGMA foreign_keys=ON;
diff --git a/packages/db/prisma/migrations/migration_lock.toml b/packages/db/prisma/migrations/migration_lock.toml
deleted file mode 100644
index e5e5c470..00000000
--- a/packages/db/prisma/migrations/migration_lock.toml
+++ /dev/null
@@ -1,3 +0,0 @@
-# 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/packages/db/prisma/schema.prisma b/packages/db/prisma/schema.prisma
deleted file mode 100644
index 3b6063a3..00000000
--- a/packages/db/prisma/schema.prisma
+++ /dev/null
@@ -1,129 +0,0 @@
-// 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?
- password String?
- image String?
- accounts Account[]
- sessions Session[]
- tags BookmarkTags[]
- bookmarks Bookmark[]
- apiKeys ApiKey[]
-}
-
-model VerificationToken {
- identifier String
- token String @unique
- expires DateTime
-
- @@unique([identifier, token])
-}
-
-model ApiKey {
- id String @id @default(cuid())
- name String
- createdAt DateTime @default(now())
- keyId String @unique
- keyHash String
- userId String
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
-
- @@unique([name, userId])
-}
-
-model Bookmark {
- id String @id @default(cuid())
- createdAt DateTime @default(now())
- archived Boolean @default(false)
- favourited Boolean @default(false)
- userId String
-
- // Content relation
- link BookmarkedLink?
-
- // Other relations
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
- tags TagsOnBookmarks[]
-}
-
-model BookmarkedLink {
- id String @id
- url String
-
- // Crawled info
- title String?
- description String?
- imageUrl String?
- favicon String?
- crawledAt DateTime?
-
- // Relations
- parentBookmark Bookmark @relation(fields: [id], references: [id], onDelete: Cascade)
-}
-
-model BookmarkTags {
- id String @id @default(cuid())
- name String
- createdAt DateTime @default(now())
-
- userId String
-
- // Relations
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
- bookmarks TagsOnBookmarks[]
-
- @@unique([userId, name])
-}
-
-model TagsOnBookmarks {
- bookmark Bookmark @relation(fields: [bookmarkId], references: [id], onDelete: Cascade)
- bookmarkId String
-
- tag BookmarkTags @relation(fields: [tagId], references: [id], onDelete: Cascade)
- tagId String
-
- attachedAt DateTime @default(now())
- attachedBy String // "human" or "ai" (if only prisma sqlite supported enums)
-
- @@unique([bookmarkId, tagId])
-}