Skip to content

Migrate notes storage to SQLite#68

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/migrate-notes-storage-to-sqlite
Draft

Migrate notes storage to SQLite#68
Copilot wants to merge 3 commits intomasterfrom
copilot/migrate-notes-storage-to-sqlite

Conversation

Copy link
Contributor

Copilot AI commented Mar 2, 2026

Replaces IntelliJ's PersistentStateComponent XML-based persistence for notes with SQLite. Includes a one-time migration so existing users don't lose data. NotesSettingsRepository remains on IntelliJ persistence as intended.

Storage layer

  • NoteDatabaseManager — SQLite CRUD via parameterized prepared statements, lazy-initialized, connection-per-operation. Database at {notesDirectory}/data/notes.db.
  • NoteStorageRepository — rewritten to delegate to NoteDatabaseManager. No longer implements PersistentStateComponent. Added changeColor(id, color) and importNote(note). updateNote now accepts optional filePath param.

Migration

  • NoteLegacyStorageRepository — retains @State(name = "NoteStorage") to read existing notes.xml data.
  • NoteMigrationService — on startup, reads legacy notes → inserts into SQLite (idempotent, skips duplicates) → clears legacy storage. Runs in AppStartupActivity.

Callers updated

  • ChangeNoteColorService — previously mutated the in-memory Note object and relied on state serialization. Now calls NoteStorageRepository.changeColor() directly.
  • RenameNoteServicefilePath was only persisted implicitly via shared object reference. Now explicitly passed to updateNote().

Schema

CREATE TABLE IF NOT EXISTS notes (
    id TEXT PRIMARY KEY,
    title TEXT NOT NULL,
    filePath TEXT NOT NULL,
    createdAt INTEGER NOT NULL,
    updatedAt INTEGER NOT NULL,
    isFavorite INTEGER NOT NULL DEFAULT 0,
    color TEXT NOT NULL DEFAULT 'NONE'
)

Tests

  • 16 tests for NoteDatabaseManager (insert, update, toggle, color, delete, persistence across instances, nested dir creation)
  • 3 tests for migration logic (field preservation, idempotency, empty source)

Dependency

  • org.xerial:sqlite-jdbc:3.49.1.0 — no known advisories.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • download.jetbrains.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Migrate notes storage to sqlite</issue_title>
<issue_description>I would like to be able to save the state of the notes, currently in this NoteStorageRepository class, in SQLite. I need it to save the same data, but in a table in SQLite, and for the queries made to the persistence to be replaced by queries in SQLite.

Currently, it is saving the data with this class and retrieving the state in the editor's own storage.

Import com.intellij.openapi.components.PersistentStateComponent

The NotesSettingsRepository continues to save using IntelliJ's persistence, so it can define editor-specific settings.

The SQLite file needs to be in the default folder where the notes are saved and inside a folder called data/.

I already have users who use this plugin and save notes in IntelliJ's persistence, so I need at least one migration that retrieves the data from the persistence and saves it to SQLite so that they don't lose their notes.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits March 2, 2026 09:35
- Add sqlite-jdbc dependency
- Create NoteDatabaseManager for SQLite CRUD operations
- Create NoteLegacyStorageRepository for migration from old XML storage
- Rewrite NoteStorageRepository to use SQLite
- Add changeColor method to NoteStorageRepository
- Update ChangeNoteColorService to use new changeColor method
- Update RenameNoteService to persist filePath changes
- Create NoteMigrationService for one-time data migration
- Update AppStartupActivity to trigger migration on startup
- Register NoteLegacyStorageRepository in plugin.xml
- Add unit tests for NoteDatabaseManager and NoteMigrationService

Co-authored-by: stanleygomes <5298153+stanleygomes@users.noreply.github.com>
Co-authored-by: stanleygomes <5298153+stanleygomes@users.noreply.github.com>
Copilot AI changed the title [WIP] Migrate notes storage to SQLite for persistence Migrate notes storage to SQLite Mar 2, 2026
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.

Migrate notes storage to sqlite

2 participants