aboutsummaryrefslogtreecommitdiffstats
path: root/packages/db/schema.ts
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2024-11-03 17:09:47 +0000
committerMohamed Bassem <me@mbassem.com>2024-11-03 17:09:47 +0000
commitcf1a25131fd45ab7c9a72b837be525c24457cd8b (patch)
treecb8b3d4a57a4ce06e500e4c7ceea43924d64a5d4 /packages/db/schema.ts
parent2efc7c8c01866fafad5322fb8783d94821e32ff1 (diff)
downloadkarakeep-cf1a25131fd45ab7c9a72b837be525c24457cd8b.tar.zst
feature: Add support for subscribing to RSS feeds. Fixes #202
Diffstat (limited to 'packages/db/schema.ts')
-rw-r--r--packages/db/schema.ts46
1 files changed, 46 insertions, 0 deletions
diff --git a/packages/db/schema.ts b/packages/db/schema.ts
index 10c69d9d..12255cfb 100644
--- a/packages/db/schema.ts
+++ b/packages/db/schema.ts
@@ -334,6 +334,52 @@ export const customPrompts = sqliteTable(
}),
);
+export const rssFeedsTable = sqliteTable(
+ "rssFeeds",
+ {
+ id: text("id")
+ .notNull()
+ .primaryKey()
+ .$defaultFn(() => createId()),
+ name: text("name").notNull(),
+ url: text("url").notNull(),
+ createdAt: createdAtField(),
+ lastFetchedAt: integer("lastFetchedAt", { mode: "timestamp" }),
+ lastFetchedStatus: text("lastFetchedStatus", {
+ enum: ["pending", "failure", "success"],
+ }).default("pending"),
+ userId: text("userId")
+ .notNull()
+ .references(() => users.id, { onDelete: "cascade" }),
+ },
+ (bl) => ({
+ userIdIdx: index("rssFeeds_userId_idx").on(bl.userId),
+ }),
+);
+
+export const rssFeedImportsTable = sqliteTable(
+ "rssFeedImports",
+ {
+ id: text("id")
+ .notNull()
+ .primaryKey()
+ .$defaultFn(() => createId()),
+ createdAt: createdAtField(),
+ entryId: text("entryId").notNull(),
+ rssFeedId: text("rssFeedId")
+ .notNull()
+ .references(() => rssFeedsTable.id, { onDelete: "cascade" }),
+ bookmarkId: text("bookmarkId").references(() => bookmarks.id, {
+ onDelete: "set null",
+ }),
+ },
+ (bl) => ({
+ feedIdIdx: index("rssFeedImports_feedIdIdx_idx").on(bl.rssFeedId),
+ entryIdIdx: index("rssFeedImports_entryIdIdx_idx").on(bl.entryId),
+ feedIdEntryIdUnique: unique().on(bl.rssFeedId, bl.entryId),
+ }),
+);
+
export const config = sqliteTable("config", {
key: text("key").notNull().primaryKey(),
value: text("value").notNull(),