diff options
| author | Mohamed Bassem <me@mbassem.com> | 2024-04-19 00:09:27 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-19 00:09:27 +0100 |
| commit | e0999f701cd1834c3d940113cd8dd5247c5fe95f (patch) | |
| tree | c4169a564ecd3f933e711bcc8ef7db20532174ea /packages/db/schema.ts | |
| parent | deba31ee010f785a9739fd4df8a64a3056c9593d (diff) | |
| download | karakeep-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.ts | 8 |
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], + }), }), ); |
