From 86d74e3f32dd5bccc8df195b55391e206df9a1c4 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Fri, 27 Dec 2024 16:09:29 +0000 Subject: feat: Implement highlights support for links. Fixes #620 --- packages/db/schema.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'packages/db/schema.ts') diff --git a/packages/db/schema.ts b/packages/db/schema.ts index 8751db31..a8fe9eeb 100644 --- a/packages/db/schema.ts +++ b/packages/db/schema.ts @@ -204,6 +204,37 @@ export const assets = sqliteTable( }), ); +export const highlights = sqliteTable( + "highlights", + { + id: text("id") + .notNull() + .primaryKey() + .$defaultFn(() => createId()), + bookmarkId: text("bookmarkId") + .notNull() + .references(() => bookmarks.id, { + onDelete: "cascade", + }), + userId: text("userId") + .notNull() + .references(() => users.id, { onDelete: "cascade" }), + startOffset: integer("startOffset").notNull(), + endOffset: integer("endOffset").notNull(), + color: text("color", { + enum: ["red", "green", "blue", "yellow"], + }).default("yellow").notNull(), + text: text("text"), + note: text("note"), + createdAt: createdAtField(), + }, + + (tb) => ({ + bookmarkIdIdx: index("highlights_bookmarkId_idx").on(tb.bookmarkId), + userIdIdx: index("highlights_userId_idx").on(tb.userId), + }), +); + export const bookmarkTexts = sqliteTable("bookmarkTexts", { id: text("id") .notNull() -- cgit v1.2.3-70-g09d2