Fixed
Status Update
Comments
yb...@google.com <yb...@google.com>
fl...@google.com <fl...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit c4fb72e4cc5fa85432d8718006281ce5c82c668c
Author: Florina Muntenescu <florinam@google.com>
Date: Wed Jul 17 08:51:17 2019
Add onDestructiveMigrate callback to Room.
Whenever all tables are dropped by Room, a onDestructiveMigrate Callback will be triggered.
Bug: 79962330
Test: DatabaseWriterTest, DatabaseCallbackTest
Change-Id: Ia04261f005aea3af8feb712f91eace68355b3df8
M room/compiler/src/main/kotlin/androidx/room/writer/SQLiteOpenHelperWriter.kt
M room/compiler/src/test/data/databasewriter/output/ComplexDatabase.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/DatabaseCallbackTest.java
M room/runtime/api/2.2.0-alpha02.txt
M room/runtime/api/current.txt
M room/runtime/api/restricted_2.2.0-alpha02.txt
M room/runtime/api/restricted_current.txt
M room/runtime/src/main/java/androidx/room/RoomDatabase.java
https://android-review.googlesource.com/1053390
https://goto.google.com/android-sha1/c4fb72e4cc5fa85432d8718006281ce5c82c668c
Branch: androidx-master-dev
commit c4fb72e4cc5fa85432d8718006281ce5c82c668c
Author: Florina Muntenescu <florinam@google.com>
Date: Wed Jul 17 08:51:17 2019
Add onDestructiveMigrate callback to Room.
Whenever all tables are dropped by Room, a onDestructiveMigrate Callback will be triggered.
Bug: 79962330
Test: DatabaseWriterTest, DatabaseCallbackTest
Change-Id: Ia04261f005aea3af8feb712f91eace68355b3df8
M room/compiler/src/main/kotlin/androidx/room/writer/SQLiteOpenHelperWriter.kt
M room/compiler/src/test/data/databasewriter/output/ComplexDatabase.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/DatabaseCallbackTest.java
M room/runtime/api/2.2.0-alpha02.txt
M room/runtime/api/current.txt
M room/runtime/api/restricted_2.2.0-alpha02.txt
M room/runtime/api/restricted_current.txt
M room/runtime/src/main/java/androidx/room/RoomDatabase.java
fl...@google.com <fl...@google.com>
mi...@gmail.com <mi...@gmail.com> #3
Thank you, thank you, Thank you Florina Muntenescu :)
fe...@gmail.com <fe...@gmail.com> #4
onDestructiveMigration() don't work for me
fe...@gmail.com <fe...@gmail.com> #5
I need do stuff before .fallbackToDestructiveMigration() is called like saving data and after call this method restore this datas
Description
Version used: 1.1.0
Devices/Android versions reproduced on: All
When we are working with Room database that contains predefined data, we can populate these predefined data when first creation of the database via Callback#onCreate(SupportSQLiteDatabase). If that project decided to fallback to destructive migration, all the predefined data will be delete during the migration and there is no way to notify if that happens so we can insert those predefined data.
My suggestion would be adding a new callback method e.g. onDestructiveMigrate(SupportSQLiteDatabase). Then notify the callback once migrated by destruction.