Fixed
Status Update
Comments
el...@google.com <el...@google.com> #2
Thanks for bringing this issue to our attention, we'll work on reproducing the issue on our end and follow up here with next steps.
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit a499a0c267f712fcc62d8227d23878a5757672c0
Author: elifbilgin <elifbilgin@google.com>
Date: Fri Jul 12 10:08:34 2024
Resolving automigration issues.
This CL resolves the issue of foreign key checks being performed too early
in the case where a column used in a foreign key was added new/renamed.
It also uncovers and fixes another issue where FTS table migrations were not
correctly handling renamed columns.
Bug: 352085724
Test: AutoMigrationTest.kt
Change-Id: I6353f94eab4af45e378106946598526c6c8af0db
M room/integration-tests/kotlintestapp/schemas-ksp/androidx.room.integration.kotlintestapp.migration.AutoMigrationDb/3.json
A room/integration-tests/kotlintestapp/schemas-ksp/androidx.room.integration.kotlintestapp.migration.AutoMigrationDb/4.json
A room/integration-tests/kotlintestapp/schemas-ksp/androidx.room.integration.kotlintestapp.migration.AutoMigrationDb/5.json
M room/integration-tests/kotlintestapp/schemas/androidx.room.integration.kotlintestapp.migration.AutoMigrationDb/3.json
A room/integration-tests/kotlintestapp/schemas/androidx.room.integration.kotlintestapp.migration.AutoMigrationDb/4.json
A room/integration-tests/kotlintestapp/schemas/androidx.room.integration.kotlintestapp.migration.AutoMigrationDb/5.json
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/migration/AutoMigrationDb.kt
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/migration/AutoMigrationTest.kt
M room/room-compiler/src/main/kotlin/androidx/room/writer/AutoMigrationWriter.kt
https://android-review.googlesource.com/3170409
Branch: androidx-main
commit a499a0c267f712fcc62d8227d23878a5757672c0
Author: elifbilgin <elifbilgin@google.com>
Date: Fri Jul 12 10:08:34 2024
Resolving automigration issues.
This CL resolves the issue of foreign key checks being performed too early
in the case where a column used in a foreign key was added new/renamed.
It also uncovers and fixes another issue where FTS table migrations were not
correctly handling renamed columns.
Bug: 352085724
Test: AutoMigrationTest.kt
Change-Id: I6353f94eab4af45e378106946598526c6c8af0db
M room/integration-tests/kotlintestapp/schemas-ksp/androidx.room.integration.kotlintestapp.migration.AutoMigrationDb/3.json
A room/integration-tests/kotlintestapp/schemas-ksp/androidx.room.integration.kotlintestapp.migration.AutoMigrationDb/4.json
A room/integration-tests/kotlintestapp/schemas-ksp/androidx.room.integration.kotlintestapp.migration.AutoMigrationDb/5.json
M room/integration-tests/kotlintestapp/schemas/androidx.room.integration.kotlintestapp.migration.AutoMigrationDb/3.json
A room/integration-tests/kotlintestapp/schemas/androidx.room.integration.kotlintestapp.migration.AutoMigrationDb/4.json
A room/integration-tests/kotlintestapp/schemas/androidx.room.integration.kotlintestapp.migration.AutoMigrationDb/5.json
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/migration/AutoMigrationDb.kt
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/migration/AutoMigrationTest.kt
M room/room-compiler/src/main/kotlin/androidx/room/writer/AutoMigrationWriter.kt
el...@google.com <el...@google.com> #4
This issue should be resolved in the next release of Room. Please let us know if you encounter the same or any other issue.
xz...@gmail.com <xz...@gmail.com> #5
Excellent, thank you very much; I'll test it when the new version comes out.
pr...@google.com <pr...@google.com> #6
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.room:room-compiler:2.7.0-alpha06
xz...@gmail.com <xz...@gmail.com> #7
Better late than never, I could test this in 2.7.0-alpha11, which works as expected. The foreign key checks are all grouped at the end of the migrations
el...@google.com <el...@google.com> #8
Thanks for the update!
Description
Version used: 2.6.1
Devices/Android versions reproduced on: All
I have multiple tables where I must add a new `appId` column.
This new `appId` is part of my foreign key constraints.
The problem is that Room applies the table migration alphabetically but then checks for the foreign key constraints after each table migration.
Therefore, my foreign key is not OK since the old table doesn't have the new column yet.
Example:
Table_A: id, name, tableB_id
Table_B: id, name
Room will add the "appId" to Table_A and set the foreign key constraint to be on the columns `tableB_id` and `appId`, then execute:
DBUtil.foreignKeyCheck(db, "Table_A");
Yet, at that point, Table_B is still: id, name — and not: id, name, appId.