-
-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- table not altered so migration from db version 3 to 4 is simple - bug fixes Signed-off-by: Arka Prava Basu <[email protected]>
- Loading branch information
Showing
3 changed files
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,13 +8,14 @@ import android.content.Context | |
import org.havenapp.main.dao.EventDAO | ||
import org.havenapp.main.dao.EventTriggerDAO | ||
import org.havenapp.main.database.converter.HavenEventDBConverters | ||
import org.havenapp.main.database.migration.RoomMigration | ||
import org.havenapp.main.model.Event | ||
import org.havenapp.main.model.EventTrigger | ||
|
||
/** | ||
* Created by Arka Prava Basu <[email protected]> on 23/5/18. | ||
*/ | ||
@Database(entities = [(Event::class), (EventTrigger::class)], version = 3) | ||
@Database(entities = [(Event::class), (EventTrigger::class)], version = 4) | ||
@TypeConverters(HavenEventDBConverters::class) | ||
abstract class HavenEventDB: RoomDatabase() { | ||
|
||
|
@@ -34,6 +35,7 @@ abstract class HavenEventDB: RoomDatabase() { | |
INSTANCE = Room.databaseBuilder(context.applicationContext, | ||
HavenEventDB::class.java, "haven.db") | ||
.allowMainThreadQueries() // todo remove this | ||
.addMigrations(RoomMigration()) | ||
.build() | ||
} | ||
} | ||
|
16 changes: 16 additions & 0 deletions
16
src/main/java/org/havenapp/main/database/migration/RoomMigration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.havenapp.main.database.migration | ||
|
||
import android.arch.persistence.db.SupportSQLiteDatabase | ||
import android.arch.persistence.room.migration.Migration | ||
|
||
/** | ||
* [Migration] for the transition from Sugar ORM (database version = 3) | ||
* to Room database (database version = 4). | ||
* <p> | ||
* Created by Arka Prava Basu <[email protected]> on 28/8/18. | ||
*/ | ||
class RoomMigration: Migration(3, 4) { | ||
override fun migrate(database: SupportSQLiteDatabase) { | ||
// Since we did not alter table, nothing to do here. | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters