Status Update
Comments
ap...@google.com <ap...@google.com> #2
In the title I was meant to write 1 new column, not 2 new columns.
da...@google.com <da...@google.com> #3
I noticed something, this is the 2.json schema file that is being generated after the above mentioned changes are completed
{
"tableName": "SubMain",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `subId` TEXT, `sideId` INTEGER, `newColumn` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`id`), FOREIGN KEY(`subId`) REFERENCES `Main`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`sideId`) REFERENCES `Side`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "subId",
"columnName": "subId",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "sideId",
"columnName": "sideId",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "text",
"columnName": "text",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "newColumn", <--- should this be created right now?
"columnName": "newColumn",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [
{
"name": "index_SubMain_subId",
"unique": false,
"columnNames": [
"subId"
],
"createSql": "CREATE INDEX IF NOT EXISTS `index_SubMain_subId` ON `${TABLE_NAME}` (`subId`)"
},
{
"name": "index_SubMain_sideId",
"unique": false,
"columnNames": [
"sideId"
],
"createSql": "CREATE INDEX IF NOT EXISTS `index_SubMain_sideId` ON `${TABLE_NAME}` (`sideId`)"
}
],
"foreignKeys": [
{
"table": "Main",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"subId"
],
"referencedColumns": [
"id"
]
},
{
"table": "Side",
"onDelete": "NO ACTION",
"onUpdate": "NO ACTION",
"columns": [
"sideId"
],
"referencedColumns": [
"id"
]
}
]
}
as you can see the field entry for the newColumn is already present, but in the previous tests I conducted before, this field would never be added at this stage (?) in order for the migration to be successful.
So I checked the Database_AutoMigration_1_2_Impl
file that is being generated by the auto migration, and I noticed that there is no entry there for adding the new columnn, when I expected to see something like this instead:
database.execSQL("ALTER TABLE 'SubMain' ADD COLUMN 'newColumn' INTEGER NOT NULL DEFAULT 0");
But yet it isn't there.
The only difference I can think of between this failing migration and the previous successful ones I did is this SubMainEntity
is written in a kotlin file, unlike the successful one I did some testing with before, which was written in a .java
file.
This does not seem right? Should the file type of an entity be enough to screw up the auto migration logic?
Description
Devices/Android versions reproduced on: Galaxy s8+ 9.0
E java.lang.ArrayIndexOutOfBoundsException: length=1; index=-1
E at java.util.BitSet.clear(BitSet.java:608)
E at androidx.room.InvalidationTracker$1.run(InvalidationTracker.java:422)
E at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E at java.lang.Thread.run(Thread.java:764)
No any other log, just crash on this log