aboutsummaryrefslogtreecommitdiffstats
path: root/packages/db/schema.ts
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2024-04-19 00:09:27 +0100
committerGitHub <noreply@github.com>2024-04-19 00:09:27 +0100
commite0999f701cd1834c3d940113cd8dd5247c5fe95f (patch)
treec4169a564ecd3f933e711bcc8ef7db20532174ea /packages/db/schema.ts
parentdeba31ee010f785a9739fd4df8a64a3056c9593d (diff)
downloadkarakeep-e0999f701cd1834c3d940113cd8dd5247c5fe95f.tar.zst
feature: Nested lists (#110). Fixes #62
* feature: Add support for nested lists * prevent moving the parent to a subtree
Diffstat (limited to 'packages/db/schema.ts')
-rw-r--r--packages/db/schema.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/packages/db/schema.ts b/packages/db/schema.ts
index 6a7128c0..037be814 100644
--- a/packages/db/schema.ts
+++ b/packages/db/schema.ts
@@ -2,6 +2,7 @@ import type { AdapterAccount } from "@auth/core/adapters";
import { createId } from "@paralleldrive/cuid2";
import { relations } from "drizzle-orm";
import {
+ AnySQLiteColumn,
index,
integer,
primaryKey,
@@ -223,9 +224,10 @@ export const bookmarkLists = sqliteTable(
userId: text("userId")
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
+ parentId: text("parentId")
+ .references((): AnySQLiteColumn => bookmarkLists.id, { onDelete: "set null" }),
},
(bl) => ({
- unq: unique().on(bl.name, bl.userId),
userIdIdx: index("bookmarkLists_userId_idx").on(bl.userId),
}),
);
@@ -318,6 +320,10 @@ export const bookmarkListsRelations = relations(
fields: [bookmarkLists.userId],
references: [users.id],
}),
+ parent: one(bookmarkLists, {
+ fields: [bookmarkLists.parentId],
+ references: [bookmarkLists.id],
+ }),
}),
);