Skip to content

Commit

Permalink
fix: add v13 to 14 DB migration
Browse files Browse the repository at this point in the history
  • Loading branch information
HashEngineering committed Sep 11, 2024
1 parent c4aa357 commit 2a7daac
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ open class DatabaseMigrationTest {

private val migrations = arrayOf(
AppDatabaseMigrations.migration11To12,
AppDatabaseMigrations.migration12To13
AppDatabaseMigrations.migration12To13,
AppDatabaseMigrations.migration13to14
)

@Rule
Expand Down
29 changes: 29 additions & 0 deletions wallet/src/de/schildbach/wallet/database/AppDatabaseMigrations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,34 @@ class AppDatabaseMigrations {
)
}
}

val migration13to14 = object : Migration(13, 14) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL(
"""
CREATE TABLE IF NOT EXISTS `imported_masternode_keys` (
`proTxHash` BLOB NOT NULL,
`address` TEXT NOT NULL,
`votingPrivateKey` BLOB NOT NULL,
`votingPublicKey` BLOB NOT NULL,
`votingPubKeyHash` BLOB NOT NULL,
PRIMARY KEY(`proTxHash`)
);
"""
)
database.execSQL(
"""
CREATE TABLE IF NOT EXISTS `username_votes` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
`username` TEXT NOT NULL,
`identity` TEXT NOT NULL,
`type` TEXT NOT NULL,
`timestamp` INTEGER NOT NULL
)
"""
)
}

}
}
}
3 changes: 2 additions & 1 deletion wallet/src/de/schildbach/wallet/di/DatabaseModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ object DatabaseModule {
return Room.databaseBuilder(context, AppDatabase::class.java, "dash-wallet-database")
.addMigrations(
AppDatabaseMigrations.migration11To12,
AppDatabaseMigrations.migration12To13
AppDatabaseMigrations.migration12To13,
AppDatabaseMigrations.migration13to14
)
// destructive migrations are used from versions 1 to 11
.fallbackToDestructiveMigration()
Expand Down

0 comments on commit 2a7daac

Please sign in to comment.