Assigned
Status Update
Comments
da...@google.com <da...@google.com> #2
there are some image for help
au...@gmail.com <au...@gmail.com> #3
hello?
pe...@googlemail.com <pe...@googlemail.com> #4
Hi, sorry for the late response.
My use case doesn't include raw INSERT
statements.
In my case, the new column must be filled with a dynamically calculated value. However, rather than handling this with the complex manual migration including creating and dropping tables (as described in my original post) I figure a 2-step process would be easier:
- Apply an auto-migration with a temporary value
- Add a much simpler manual migration, which is only a data migration (without schema changes) to set the actual values.
In this case, it would bother me and mislead my colleagues if the temporary value used in step 1 would remain as an artifact in form of the DEFAULT
declaration in the table schema and as ColumnInfo
annotation.
Description
Component used: androidx.room
Version used: 2.6.1
Adding a column to a table is a common migration scenario, where the new column has one of these requirements:
1 and 2 can be handled with auto-migrations. 2 requires the new property being annotated with e.g.
@ColumnInfo(defaultValue = "")
.Scenario 3 - while arguably not less common - is not covered by auto-migrations.
Instead it requires a manual migration executing multiple SQL statements:
What I would like to see is 3 being covered by an auto-migration with an auto-migration-spec annotation, which allows for defining a default value (for the migration only). It could look like this:
This by itself would cover a lot of cases. In case the column needs to be populated with dynamic values, a manual migration could be appended which would be way easier (basically only step 3 from above).
This could be implemented with the steps shown above but spare the app developer from the complexity. I'd appreciate if you'd consider it.