[PR #2531] feat: better handling for re-adding existing bookmarks #2145

Open
opened 2026-03-02 12:00:45 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/karakeep-app/karakeep/pull/2531
Author: @MohamedBassem
Created: 2/28/2026
Status: 🔄 Open

Base: mainHead: claude/bookmark-lastsaved-sorting-ZY5o0


📝 Commits (1)

  • 574b560 feat: add lastSavedAt field for bookmark sorting and re-save behavior

📊 Changes

7 files changed (+3458 additions, -19 deletions)

View changed files

packages/db/drizzle/0081_add_last_saved_at.sql (+5 -0)
packages/db/drizzle/meta/0081_snapshot.json (+3385 -0)
📝 packages/db/drizzle/meta/_journal.json (+7 -0)
📝 packages/db/schema.ts (+20 -0)
📝 packages/shared/types/bookmarks.ts (+1 -0)
📝 packages/trpc/models/bookmarks.ts (+22 -16)
📝 packages/trpc/routers/bookmarks.ts (+18 -3)

📄 Description

Summary

This PR adds a lastSavedAt timestamp field to bookmarks to track when a bookmark was last saved or updated, separate from the creation timestamp.

Key Changes

  • Database Schema: Added lastSavedAt integer column to the bookmarks table with a default value of the current timestamp
  • Migration: Created migration 0081_add_last_saved_at that:
    • Adds the new lastSavedAt column
    • Backfills existing bookmarks with their createdAt value
    • Creates an index on userId and lastSavedAt for efficient querying
  • Model Layer: Added lastSavedAt getter to BareBookmark class to expose the new field
  • Type Definitions: Updated zBareBookmarkSchema to include the lastSavedAt date field

Implementation Details

  • The lastSavedAt field defaults to the current date/time when a bookmark is created
  • Existing bookmarks are backfilled with their creation timestamp to maintain data consistency
  • The field is indexed alongside userId to support efficient queries filtering by save time

Fixes #2502


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/karakeep-app/karakeep/pull/2531 **Author:** [@MohamedBassem](https://github.com/MohamedBassem) **Created:** 2/28/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `claude/bookmark-lastsaved-sorting-ZY5o0` --- ### 📝 Commits (1) - [`574b560`](https://github.com/karakeep-app/karakeep/commit/574b56004c3a89970408208e708639dc28a8f37d) feat: add lastSavedAt field for bookmark sorting and re-save behavior ### 📊 Changes **7 files changed** (+3458 additions, -19 deletions) <details> <summary>View changed files</summary> ➕ `packages/db/drizzle/0081_add_last_saved_at.sql` (+5 -0) ➕ `packages/db/drizzle/meta/0081_snapshot.json` (+3385 -0) 📝 `packages/db/drizzle/meta/_journal.json` (+7 -0) 📝 `packages/db/schema.ts` (+20 -0) 📝 `packages/shared/types/bookmarks.ts` (+1 -0) 📝 `packages/trpc/models/bookmarks.ts` (+22 -16) 📝 `packages/trpc/routers/bookmarks.ts` (+18 -3) </details> ### 📄 Description ## Summary This PR adds a `lastSavedAt` timestamp field to bookmarks to track when a bookmark was last saved or updated, separate from the creation timestamp. ## Key Changes - **Database Schema**: Added `lastSavedAt` integer column to the `bookmarks` table with a default value of the current timestamp - **Migration**: Created migration `0081_add_last_saved_at` that: - Adds the new `lastSavedAt` column - Backfills existing bookmarks with their `createdAt` value - Creates an index on `userId` and `lastSavedAt` for efficient querying - **Model Layer**: Added `lastSavedAt` getter to `BareBookmark` class to expose the new field - **Type Definitions**: Updated `zBareBookmarkSchema` to include the `lastSavedAt` date field ## Implementation Details - The `lastSavedAt` field defaults to the current date/time when a bookmark is created - Existing bookmarks are backfilled with their creation timestamp to maintain data consistency - The field is indexed alongside `userId` to support efficient queries filtering by save time Fixes #2502 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/karakeep#2145
No description provided.