Skip to content

feat: migrate bookmark storage from JSON/workspaceState to Drizzle ORM + SQLite#50

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/update-bookmark-storage-drizzle-orm
Draft

feat: migrate bookmark storage from JSON/workspaceState to Drizzle ORM + SQLite#50
Copilot wants to merge 2 commits intomainfrom
copilot/update-bookmark-storage-drizzle-orm

Conversation

Copy link
Copy Markdown

Copilot AI commented May 2, 2026

Replaces the existing bookmark persistence mechanism (.vscode/bookmark-manager.json and VSCode workspaceState) with a SQLite database managed via Drizzle ORM, stored in the extension's home directory (~/.config/bookmark-manager/bookmarks.db).

Schema

Four tables defined in src/database/schema.ts:

  • bookmarks — full bookmark data per workspace
  • bookmark_groups — custom group definitions
  • store_meta — per-workspace view preferences (viewType, groupView, sortedType, version)
  • group_info — sorted order for grouping views

New: DatabaseService

src/services/DatabaseService.ts exposes:

  • save(workspaceName, storeInfo) — transactional upsert of all data for a workspace
  • load(workspaceName) — returns IBookmarkStoreInfo | null
  • has(workspaceName) — existence check
  • delete(workspaceName) — removes all data for a workspace

Controller changes

BookmarksController.save() now routes to _saveToDatabase() instead of workspaceState when createJsonFile=false. On first load, old workspaceState data is migrated to SQLite automatically and cleared.

// Before
this.workspaceState.update(EXTENSION_ID, this._store);

// After
this._saveToDatabase(); // per-workspace rows in SQLite
this.workspaceState.update(EXTENSION_ID, null); // clear legacy state

Multi-workspace support: _loadFromDatabase() merges data across all workspace folders, deduplicating groups and groupInfo entries.

Bundling

better-sqlite3 is a native addon — externalized in webpack config and explicitly included in .vscodeignore (negation pattern) so it ships with the packaged extension. skipLibCheck: true added to tsconfig.json to suppress unrelated type errors from drizzle-orm's optional peer adapters.

Copilot AI and others added 2 commits May 2, 2026 03:19
- Add drizzle-orm and better-sqlite3 dependencies
- Create database schema (bookmarks, bookmark_groups, store_meta, group_info tables)
- Create DatabaseService with save/load/delete/has operations
- Update BookmarksController to use SQLite instead of workspaceState when createJsonFile=false
- Keep workspaceState data migration path for backwards compatibility
- Externalize better-sqlite3 native module in webpack config
- Update .vscodeignore to include better-sqlite3 native module
- Add skipLibCheck to tsconfig.json for drizzle-orm type compatibility

Agent-Logs-Url: https://github.com/czfadmin/bookmarks/sessions/638f637a-8d9e-48ba-b0ba-89527569fdb3

Co-authored-by: czfadmin <13393959+czfadmin@users.noreply.github.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 2, 2026

⚠️ No Changeset found

Latest commit: 2a52cb5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants