Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump room to 2.6.0 #3396

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ ext {
parcelerVersion = "1.1.13"
prismVersion = "2.0.0"
retrofit2Version = "2.9.0"
roomVersion = "2.5.2"
roomVersion = "2.6.0"
workVersion = "2.8.1"
espressoVersion = "3.5.1"
media3_version = "1.1.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@ import androidx.sqlite.db.SupportSQLiteDatabase
@Suppress("MagicNumber")
object Migrations {
val MIGRATION_6_8 = object : Migration(6, 8) {
override fun migrate(database: SupportSQLiteDatabase) {
override fun migrate(db: SupportSQLiteDatabase) {
Log.i("Migrations", "Migrating 6 to 8")
migrateToRoom(database)
migrateToRoom(db)
}
}

val MIGRATION_7_8 = object : Migration(7, 8) {
override fun migrate(database: SupportSQLiteDatabase) {
override fun migrate(db: SupportSQLiteDatabase) {
Log.i("Migrations", "Migrating 7 to 8")
migrateToRoom(database)
migrateToRoom(db)
}
}

val MIGRATION_8_9 = object : Migration(8, 9) {
override fun migrate(database: SupportSQLiteDatabase) {
override fun migrate(db: SupportSQLiteDatabase) {
Log.i("Migrations", "Migrating 8 to 9")
migrateToDualPrimaryKeyArbitraryStorage(database)
migrateToDualPrimaryKeyArbitraryStorage(db)
}
}

fun migrateToRoom(database: SupportSQLiteDatabase) {
database.execSQL(
fun migrateToRoom(db: SupportSQLiteDatabase) {
db.execSQL(
"CREATE TABLE User_new (" +
"id INTEGER NOT NULL, " +
"userId TEXT, " +
Expand All @@ -65,7 +65,7 @@ object Migrations {
"PRIMARY KEY(id)" +
")"
)
database.execSQL(
db.execSQL(
"CREATE TABLE ArbitraryStorage_new (" +
"accountIdentifier INTEGER NOT NULL, " +
"\"key\" TEXT, " +
Expand All @@ -75,7 +75,7 @@ object Migrations {
")"
)
// Copy the data
database.execSQL(
db.execSQL(
"INSERT INTO User_new (" +
"id, userId, username, baseUrl, token, displayName, pushConfigurationState, capabilities, " +
"clientCertificate, externalSignalingServer, current, scheduledForDeletion) " +
Expand All @@ -84,24 +84,24 @@ object Migrations {
"clientCertificate, externalSignalingServer, current, scheduledForDeletion " +
"FROM User"
)
database.execSQL(
db.execSQL(
"INSERT INTO ArbitraryStorage_new (" +
"accountIdentifier, \"key\", object, value) " +
"SELECT " +
"accountIdentifier, \"key\", object, value " +
"FROM ArbitraryStorage"
)
// Remove the old table
database.execSQL("DROP TABLE User")
database.execSQL("DROP TABLE ArbitraryStorage")
db.execSQL("DROP TABLE User")
db.execSQL("DROP TABLE ArbitraryStorage")

// Change the table name to the correct one
database.execSQL("ALTER TABLE User_new RENAME TO User")
database.execSQL("ALTER TABLE ArbitraryStorage_new RENAME TO ArbitraryStorage")
db.execSQL("ALTER TABLE User_new RENAME TO User")
db.execSQL("ALTER TABLE ArbitraryStorage_new RENAME TO ArbitraryStorage")
}

fun migrateToDualPrimaryKeyArbitraryStorage(database: SupportSQLiteDatabase) {
database.execSQL(
fun migrateToDualPrimaryKeyArbitraryStorage(db: SupportSQLiteDatabase) {
db.execSQL(
"CREATE TABLE ArbitraryStorage_dualPK (" +
"accountIdentifier INTEGER NOT NULL, " +
"\"key\" TEXT NOT NULL, " +
Expand All @@ -111,17 +111,17 @@ object Migrations {
")"
)
// Copy the data
database.execSQL(
db.execSQL(
"INSERT INTO ArbitraryStorage_dualPK (" +
"accountIdentifier, \"key\", object, value) " +
"SELECT " +
"accountIdentifier, \"key\", object, value " +
"FROM ArbitraryStorage"
)
// Remove the old table
database.execSQL("DROP TABLE ArbitraryStorage")
db.execSQL("DROP TABLE ArbitraryStorage")

// Change the table name to the correct one
database.execSQL("ALTER TABLE ArbitraryStorage_dualPK RENAME TO ArbitraryStorage")
db.execSQL("ALTER TABLE ArbitraryStorage_dualPK RENAME TO ArbitraryStorage")
}
}