Номер версии 1.1.0.
Я получаю эту ошибку при первом запуске после миграции.
Он работает хорошо, если я закрываю приложение и запускаю его снова.
ROOM: Cannot run invalidation tracker. Is the db closed?
java.lang.IllegalStateException: Cannot perform this operation because the connection pool has been closed.
at android.database.sqlite.SQLiteConnectionPool.throwIfClosedLocked(SQLiteConnectionPool.java:1182)
at android.database.sqlite.SQLiteConnectionPool.waitForConnection(SQLiteConnectionPool.java:792)
at android.database.sqlite.SQLiteConnectionPool.acquireConnection(SQLiteConnectionPool.java:518)
Caused By : SQL(query) error or missing database.
(no such table: room_table_modification_log (code 1): , while compiling: DELETE FROM proposals WHERE hotel_id = ?)
#################################################################
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1095)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:660)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1417)
at android.arch.persistence.db.framework.FrameworkSQLiteDatabase.compileStatement(FrameworkSQLiteDatabase.java:64)
at android.arch.persistence.room.RoomDatabase.compileStatement(RoomDatabase.java:244)
at android.arch.persistence.room.SharedSQLiteStatement.createNewStatement(SharedSQLiteStatement.java:65)
at android.arch.persistence.room.SharedSQLiteStatement.getStmt(SharedSQLiteStatement.java:77)
at android.arch.persistence.room.SharedSQLiteStatement.acquire(SharedSQLiteStatement.java:87)
at com.hotellook.db.dao.FavoritesDao_Impl.removeProposals(FavoritesDao_Impl.java:723)
Код инициализации DB выглядит так (Dagger AppModule)
@Provides
@Singleton
fun provideDataBase(app: Application): AppDatabase =
Room.databaseBuilder(app, AppDatabase::class.java, DATABASE_NAME)
.addMigrations(MIGRATION_1_2)
.addMigrations(MIGRATION_2_3)
.build()
private companion object {
const val DATABASE_NAME = "app.db"
val MIGRATION_1_2 = object : Migration(1, 2) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE table1 ADD COLUMN column0 TEXT;")
database.execSQL("ALTER TABLE table2 ADD COLUMN column0 TEXT;")
}
}
val MIGRATION_2_3 = object : Migration(2, 3) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("CREATE TABLE table0 (column1 INTEGER NOT NULL, column2 TEXT NOT NULL, PRIMARY KEY(column1))")
database.execSQL("ALTER TABLE table1 ADD COLUMN column1 TEXT;")
database.execSQL("ALTER TABLE table1 ADD COLUMN column2 TEXT;")
database.execSQL("ALTER TABLE table1 ADD COLUMN column3 REAL;")
database.execSQL("ALTER TABLE table2 ADD COLUMN column1 TEXT;")
database.execSQL("ALTER TABLE table2 ADD COLUMN column2 REAL;")
database.execSQL("ALTER TABLE table3 ADD COLUMN column1 INTEGER DEFAULT 0;")
database.execSQL("ALTER TABLE table3 ADD COLUMN column2 TEXT;")
}
}
Обновление приложения от версии 2 до 3. Как я могу его исправить?