I migrated DTO structure and made changes in the D...
# compose-desktop
b
I migrated DTO structure and made changes in the Data classes of response too, now I'm getting this error from Room on inserting item. In android, I was able to fix by re-installing it and changing the version number as well. How do I re-install desktop app clean? I tried doing it from configurations, but can't find a way. Found a similar issue in SO: https://stackoverflow.com/questions/78425998/create-and-run-task-when-installing-uninstalling-compose-desktop-app
n
you should not rely on reinstalling the app. when sending to production, you will not be able to request users to reinstall in full. in order to update, after changing the version, you need to provide migration objects that reflect your changes and that are applied when the app starts after the update: // empty migration, just so you understand how it works
Copy code
private val MIGRATION_1_2: Migration = object : Migration(1, 2) {
    override fun migrate(database: SupportSQLiteDatabase) {}
}
// added a new value in the data class so i am adding it in the database too
Copy code
private val MIGRATION_2_3: Migration = object : Migration(2, 3) {
    override fun migrate(database: SupportSQLiteDatabase) {
        database.execSQL("ALTER TABLE yourTableName ADD COLUMN someNewColumn INTEGER")
    }
}
After doing these, you need to add them to the databaseBuilder as :
Copy code
Room.databaseBuilder(.....)
    .addMigrations(
        MIGRATION_1_2,
        MIGRATION_2_3)
    .build()
hope this will solve your issue 🙂
b
Thanks it worked! It's 4 am here and I'm debugging this since last 1-2 hours 😢 I learned something amazing today, thanks to you!! 😄
💯 1
n
Glad it worked out!
K 1