Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
It would be very helpful if
AutoMigrationSpec
had anonPreMigrate
hook.Example use case:
I am modifying
FooEntity
to add an FK constraint toBarEntity
.This is easy to do with an
AutoMigration
, Room handles migrating the data for you.However, it's possible the database may contain data that does not meet this constraint (adding the constraint is intended to prevent this in the future).
If this data is not deleted the migration will fail (and fail on every attempt).
If an
onPreMigrate
hook existed I could use this to find and delete anyFooEntity
that don't meet the constraint.Alternatives
At the moment you either have to:
Migration
, and write all the code yourself.Migration
that does the deletion, the second is anAutoMigration
where Room generates the code to add the constraint.