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)
Attachment actions
Unintended behavior
View staffing
Description
Version used: 1.0.0-alpha3
Devices/Android versions reproduced on: Nexus 5X (ODP3)
While runMigrationsAndValidate() does check for invalid table structures, it does not check for the existence or validity of indexes.
Suppose the real migration should be:
static final Migration FROM_1_TO_2=new Migration(1,2) {
@Override
public void migrate(SupportSQLiteDatabase db) {
db.execSQL("CREATE TABLE IF NOT EXISTS `lodgings` (`id` TEXT, `title` TEXT, `duration` INTEGER, `priority` INTEGER, `startTime` INTEGER, `creationTime` INTEGER, `updateTime` INTEGER, `address` TEXT, `tripId` TEXT, PRIMARY KEY(`id`), FOREIGN KEY(`tripId`) REFERENCES `trips`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )");
db.execSQL("CREATE INDEX `index_lodgings_tripId` ON `lodgings` (`tripId`)");
db.execSQL("CREATE TABLE IF NOT EXISTS `flights` (`id` TEXT, `title` TEXT, `duration` INTEGER, `priority` INTEGER, `startTime` INTEGER, `creationTime` INTEGER, `updateTime` INTEGER, `departingAirport` TEXT, `arrivingAirport` TEXT, `airlineCode` TEXT, `flightNumber` TEXT, `seatNumber` TEXT, `tripId` TEXT, PRIMARY KEY(`id`), FOREIGN KEY(`tripId`) REFERENCES `trips`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )");
db.execSQL("CREATE INDEX `index_flights_tripId` ON `flights` (`tripId`)");
}
};
This migration passes the runMigrationsAndValidate() test:
static final Migration BROKEN_1_TO_2=new Migration(1,2) {
@Override
public void migrate(SupportSQLiteDatabase db) {
db.execSQL("CREATE TABLE IF NOT EXISTS `lodgings` (`id` TEXT, `title` TEXT, `duration` INTEGER, `priority` INTEGER, `startTime` INTEGER, `creationTime` INTEGER, `updateTime` INTEGER, `address` TEXT, `tripId` TEXT, PRIMARY KEY(`id`), FOREIGN KEY(`tripId`) REFERENCES `trips`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )");
db.execSQL("CREATE TABLE IF NOT EXISTS `flights` (`id` TEXT, `title` TEXT, `duration` INTEGER, `priority` INTEGER, `startTime` INTEGER, `creationTime` INTEGER, `updateTime` INTEGER, `departingAirport` TEXT, `arrivingAirport` TEXT, `airlineCode` TEXT, `flightNumber` TEXT, `seatNumber` TEXT, `tripId` TEXT, PRIMARY KEY(`id`), FOREIGN KEY(`tripId`) REFERENCES `trips`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )");
}
};
...despite the fact that neither index found in the schema JSON was created.
The attached project illustrates the problem. The MigrationTests right now uses BROKEN_1_TO_2, which should fail but does not.