Skip to content

Fix vault data loss caused by destructive migration fallback - #2

Merged
loic-daigle merged 8 commits into
masterfrom
copilot/fix-vault-permanence-issue
Nov 5, 2025
Merged

loic-daigle merged 8 commits into
masterfrom
copilot/fix-vault-permanence-issue

Conversation

Copilot AI commented Nov 5, 2025 •

Copy link
Copy Markdown
Contributor

User vaults were being deleted during app updates. Room's .fallbackToDestructiveMigration() was configured to drop all tables when migrations failed or were missing, and MIGRATION_11_12 was incomplete.

Changes

Removed destructive migration

  • Removed .fallbackToDestructiveMigration() from database builder
  • Prevents automatic data deletion on schema mismatches

Added comprehensive migration coverage

  • Implemented migrations for all version paths (1→12 through 11→12)
  • Shared migrateToV12 function ensures consistent migration logic across all paths
  • Defensive column/table existence checks prevent duplicate creation errors

Fixed schema gaps

  • Added missing createdAt column to vault table migrations
  • Added DEFAULT 0 for reconciled column in vault_contributions table
  • Ensures all non-nullable columns have appropriate defaults
// Before: data loss on version mismatch
Room.databaseBuilder(...)
    .addMigrations(MIGRATION_11_12)
    .fallbackToDestructiveMigration()  // ← destroys user data
    .build()

// After: safe migrations preserve all data
Room.databaseBuilder(...)
    .addMigrations(
        MIGRATION_1_12, MIGRATION_2_12, ..., MIGRATION_11_12
    )
    .build()

All migrations now use idempotent SQL (CREATE TABLE IF NOT EXISTS, PRAGMA table_info checks) to safely handle existing schemas.

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:

  • dl.google.com
    • Triggering command: /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.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/gradle-daemon-main-8.13.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/agents/gradle-instrumentation-agent-8.13.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.13 (dns block)

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

Original prompt

There is a fucking problem that keeps clearing my fucking vaults!!!! They should be permanent!!! Not disappear after 3 days!!!!


✨ 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 7 commits November 5, 2025 03:10
Co-authored-by: The-Young-Maker <66848791+The-Young-Maker@users.noreply.github.com>
…s to preserve vault data

Co-authored-by: The-Young-Maker <66848791+The-Young-Maker@users.noreply.github.com>
Co-authored-by: The-Young-Maker <66848791+The-Young-Maker@users.noreply.github.com>
… integrity

Co-authored-by: The-Young-Maker <66848791+The-Young-Maker@users.noreply.github.com>
Co-authored-by: The-Young-Maker <66848791+The-Young-Maker@users.noreply.github.com>
…ToV12 function

Co-authored-by: The-Young-Maker <66848791+The-Young-Maker@users.noreply.github.com>
…t behavior

Co-authored-by: The-Young-Maker <66848791+The-Young-Maker@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with vaults disappearing after three days Fix vault data loss caused by destructive migration fallback Nov 5, 2025
Copilot AI requested a review from loic-daigle November 5, 2025 03:24
@loic-daigle
loic-daigle marked this pull request as ready for review November 5, 2025 22:49
@loic-daigle
loic-daigle merged commit e2106be into master Nov 5, 2025
@loic-daigle
loic-daigle deleted the copilot/fix-vault-permanence-issue branch November 5, 2025 22:50
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