'MigrationTestHelper doesn't handle constraints

I have a simple Rooms tests like

@Test
@Throws(IOException::class)
fun migrate_1_2() {
    helper.createDatabase(TEST_DB, 1).apply {
        insert("UserEntity", SQLiteDatabase.CONFLICT_IGNORE, ContentValues().apply {
            put("login", "[email protected]")
            putNull("roles")
        })
        close()
    }

    helper.runMigrationsAndValidate(TEST_DB, 2, true, MIGRATION_1_2)
}

but I got an issue with

putNull("roles")

CREATE TABLE ... `roles` TEXT NOT NULL,...

and other variants of NOT NULL constraints. DB tests allow inserts into NOT NULL fields on migration and doesn't fire any exceptions on it, but I still have a problem on migrations on device

Is it a bug of MigrationTestHelper or there is some config somewhere?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source