Skip to content

feat(database): start fresh installs on a native DuckDB database #2191

Closed

Description

@shm11C3

Outcome

A first launch with no existing database creates the native DuckDB database directly and runs on it. No SQLite file is created, and no conversion is involved.

Related to #2090 and required by ADR 0025 (retiring the SQLite conversion path in v2.0.0): the SQLite backend cannot be removed while every new install still begins on it.

Current behavior (verified on develop)

  • inspect_authority returns SqliteAuthoritative when there is no SQLite source, no native file, no marker and no work directory. Its own comment names this "the ordinary state before any conversion, and after a fresh install".
  • App startup then calls db::init and applies the SQLite migrations, which creates hv-database.db.
  • The only code that ever writes a native database is finalization, which copies a candidate built from a SQLite snapshot. Nothing creates the stable schema, the native metadata row, the identity table and the authority marker from nothing.

So a user who installs a build with duckdb-archive enabled still starts on SQLite and has to convert later.

Scope and verification

  • Core: one operation that creates an empty native database from the App-owned stable schema (get_native_schema()), with the metadata row already selected, the pinned storage version recorded, the identity high-water marks initialised, and the authority marker written in the same database-first order select_native_database uses. It refuses to run if a SQLite source, a native file, a marker or a conversion work directory already exists; it never overwrites.
  • App: the lifecycle owner decides at startup. "Nothing exists" becomes "create native and run on it" instead of SqliteAuthoritative; every other state keeps its current meaning. SQLite migrations do not run on that path, so no source is created as a side effect.
  • The result must be indistinguishable from a converted database for every consumer: the dispatch boundary adopts it, producers write to it, a restart reports NativeAuthoritative, and SQLite retirement finds nothing to rename and does nothing.
  • Interruption: a crash between creating the file and writing the marker must resolve on the next start without guessing. Reuse the existing SelectedWithoutMarker repair if the database already says selected; otherwise a half-created file with no history in it may be discarded and recreated, and that is the one case where discarding is safe. State this explicitly in code and tests.
  • Decide and record when this becomes the default. It must not reach users before investigate(database): qualify production enablement of the duckdb-archive feature #2137 qualifies production enablement, and it changes what SqliteAuthoritative means for a fresh profile, so it should be gated until then.
  • Tests: fresh creation end to end through the dispatch boundary; refusal when any of the four artifacts exists; restart after creation; the interrupted-creation cases; and the existing differential suites still passing, since a created database and a converted empty one must have the same shape.

Out of scope

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:backendarea:tauri

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions