Skip to content

Draft: investigate idempotent database initialization for new-db#5215

Draft
Copilot wants to merge 1 commit intomasterfrom
copilot/add-idempotent-database-initialization
Draft

Draft: investigate idempotent database initialization for new-db#5215
Copilot wants to merge 1 commit intomasterfrom
copilot/add-idempotent-database-initialization

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 9, 2026

new-db is currently destructive, which makes it unsuitable for safe startup-time initialization in dynamic environments. The intended change is to provide an idempotent way to initialize schema without wiping existing database state.

  • Current status

    • No repository code changes were committed in this iteration.
    • Investigation narrowed the change to the new-db command path and the database initialization flow in:
      • src/main/CommandLine.cpp
      • src/main/ApplicationUtils.cpp
      • src/main/ApplicationImpl.cpp
      • src/database/Database.cpp
  • Planned implementation shape

    • Add a non-destructive initialization mode to new-db (for example, --init-only).
    • Route that mode through a separate database initialization path instead of Database::initialize(), which currently deletes SQLite database files and recreates tables.
    • Preserve existing new-db behavior when the new flag is not used.
  • Key constraint identified

    • Database::initialize() is destructive by design:
      if (isSqlite())
      {
          // closes and removes existing SQLite files
      }
      
      OverlayManager::maybeDropAndCreateNew(mSession);
      PersistentState::maybeDropAndCreateNew(*this);
      LedgerHeaderUtils::maybeDropAndCreateNew(*this);
    • The idempotent path needs separate table/schema bootstrap logic that does not drop existing state.

Copilot AI linked an issue Apr 9, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add idempotent way to initialize database Draft: investigate idempotent database initialization for new-db Apr 9, 2026
Copilot AI requested a review from anupsdf April 9, 2026 22:51
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.

Provide idempotent way to initalise database

2 participants