Skip to content

[Bug] App fails to launch (panic during setup hook) when migrating from older legacy global index: no such table legacy_index.memo_lifecycles #55

Description

@HuaShenYay

Environment

  • OS: macOS (Apple Silicon darwin-aarch64)
  • Flowix Version: 1.4.6 (upgraded from an older version)

Describe the Bug / 现象描述

When launching Flowix 1.4.6 upgraded from an older version (whose global ~/.flowix/index.db schema was from before memo_relative_paths_v1 and memo_lifecycles migrations), the application crashes immediately upon launch during the Tauri setup hook.

Terminal panic output:

thread 'main' panicked at .../tauri-2.11.3/src/app.rs:1425:11:
Failed to setup app: error encountered during setup hook: no such table: legacy_index.memo_lifecycles

If legacy_index.memo_lifecycles table is manually created, it then panics with:

Failed to setup app: error encountered during setup hook: no such column: relative_path in INSERT OR IGNORE INTO memos
                    (id, notebook_id, filename, relative_path, preview, thumbnail, thumbnail_checked, agents_checked, created_at, updated_at, favorited, icon, properties)
                 SELECT id, notebook_id, filename, relative_path, preview, thumbnail, thumbnail_checked, agents_checked, created_at, updated_at, favorited, icon, properties
                 FROM legacy_index.memos WHERE notebook_id = ?1 at offset 250

And similarly for legacy_index.memo_todos missing the todo_id column.

Root Cause Analysis / 原因定位

In app/flowix-core/src/memo_file/index_store/schema.rs, import_legacy_global_memo_index() attaches ~/.flowix/index.db as legacy_index to migrate records into the notebook-level notebook.db:

tx.execute(
    "INSERT OR IGNORE INTO memo_lifecycles
        (memo_id, notebook_id, relative_path, generation, is_deleted, created_at, updated_at, deleted_at)
     SELECT memo_id, notebook_id, relative_path, generation, is_deleted, created_at, updated_at, deleted_at
     FROM legacy_index.memo_lifecycles WHERE notebook_id = ?1",
    [notebook_id],
)?;

While optional tables like memo_content_revisions handle missing tables gracefully via:

.or_else(|error| {
    if error.to_string().contains("no such table") {
        Ok(0)
    } else {
        Err(error)
    }
})?;

The migration queries for legacy_index.memo_lifecycles, legacy_index.memos.relative_path, and legacy_index.memo_todos.todo_id assume that legacy_index already ran all intermediate migrations.

For users upgrading directly from an older release where ~/.flowix/index.db only completed earlier migrations (e.g. notebook_tags_v1), these tables and columns do not exist in the legacy global DB, causing uncaught SQLite errors that panic Tauri's setup hook.

Suggested Solutions / 建议修复方案

  1. Schema Tolerance in Migration:
    • For legacy_index.memo_lifecycles: handle no such table with Ok(0) just like memo_content_revisions.
    • For memos: check column existence via PRAGMA table_info or fallback to SELECT id, notebook_id, filename, filename AS relative_path, ... FROM legacy_index.memos.
    • For memo_todos: check if todo_id exists, or fallback/generate default IDs if upgrading from the old schema where PRIMARY KEY(memo_id, content).
  2. Or Pre-run Migrations:
    • Ensure historical migrations (migrate_memo_relative_paths, migrate_memo_todo_ids, migrate_memo_lifecycles) are executed on the legacy global database connection before invoking import_legacy_global_memo_index().

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions