Last active
January 26, 2022 13:35
-
-
Save mathemandy/8cca63ea3e7b24c405505be73cff857d to your computer and use it in GitHub Desktop.
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
val MIGRATION_8_9 = object : Migration(8, 9) { | |
override fun migrate(database: SupportSQLiteDatabase) { | |
database.execSQL("CREATE TABLE `savedAlbums_new` (`entityOwnerId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `id` TEXT NOT NULL, `artwork` TEXT, `artist` TEXT, `description` TEXT, `album_genre` TEXT, `name` TEXT, `presave` INTEGER NOT NULL, `artist_name` TEXT, `label` TEXT, `created` INTEGER NOT NULL, `modified` INTEGER NOT NULL, `releasedate` INTEGER NOT NULL, `entityOwner` TEXT, `uniqueId` TEXT, `indexInQueue` INTEGER NOT NULL default -1, `sharelink` TEXT)") | |
database.execSQL("CREATE UNIQUE INDEX `index_savedAlbums_uniqueId` ON `savedAlbums_new` (`uniqueId`)") | |
database.execSQL("INSERT INTO `savedAlbums_new` (`id` , `artwork`, `artist` , `description` , `album_genre`, `name` , `presave` , `artist_name`, `label` , `created` , `modified` , `releasedate`, `entityOwner`) select `id` , `artwork`, `artist` , `description` , `album_genre`, `name` , `presave` , `artist_name`, `label` , `created` , `modified` , `releasedate`, `entityOwner` from savedAlbums ") | |
database.execSQL(" DROP TABLE savedAlbums ") | |
database.execSQL("ALTER TABLE savedAlbums_new RENAME TO savedAlbums") | |
} | |
.... | |
.... | |
Room.databaseBuilder(androidApplication(), xxxDatabase::class.java, "xxxDabase") | |
.addMigrations(MIGRATION_8_9) | |
.build() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps: