fixes a crash within TootDao that is caused by an change in the room library
This commit is contained in:
parent
bb376cfd6c
commit
ed851cb04d
@ -59,7 +59,7 @@ dependencies {
|
|||||||
compile "org.jsoup:jsoup:1.10.3"
|
compile "org.jsoup:jsoup:1.10.3"
|
||||||
|
|
||||||
//room
|
//room
|
||||||
compile "android.arch.persistence.room:runtime:1.0.0-beta2"
|
compile "android.arch.persistence.room:runtime:1.0.0-rc1"
|
||||||
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0-beta2'
|
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0-beta2'
|
||||||
|
|
||||||
testCompile "junit:junit:4.12"
|
testCompile "junit:junit:4.12"
|
||||||
|
@ -54,6 +54,7 @@ public class TuskyApplication extends Application {
|
|||||||
|
|
||||||
db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "tuskyDB")
|
db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "tuskyDB")
|
||||||
.allowMainThreadQueries()
|
.allowMainThreadQueries()
|
||||||
|
.addMigrations(AppDatabase.MIGRATION_2_3)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,14 +1,30 @@
|
|||||||
package com.keylesspalace.tusky.db;
|
package com.keylesspalace.tusky.db;
|
||||||
|
|
||||||
|
import android.arch.persistence.db.SupportSQLiteDatabase;
|
||||||
import android.arch.persistence.room.Database;
|
import android.arch.persistence.room.Database;
|
||||||
import android.arch.persistence.room.RoomDatabase;
|
import android.arch.persistence.room.RoomDatabase;
|
||||||
|
import android.arch.persistence.room.migration.Migration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DB version & declare DAO
|
* DB version & declare DAO
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Database(entities = {TootEntity.class}, version = 2, exportSchema = false)
|
@Database(entities = {TootEntity.class}, version = 3, exportSchema = false)
|
||||||
public abstract class AppDatabase extends RoomDatabase {
|
public abstract class AppDatabase extends RoomDatabase {
|
||||||
|
|
||||||
public abstract TootDao tootDao();
|
public abstract TootDao tootDao();
|
||||||
|
|
||||||
|
public static final Migration MIGRATION_2_3 = new Migration(2, 3) {
|
||||||
|
@Override
|
||||||
|
public void migrate(SupportSQLiteDatabase database) {
|
||||||
|
//this migration is necessary because of a change in the room library
|
||||||
|
database.execSQL("CREATE TABLE TootEntity2 (uid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, text TEXT, urls TEXT, contentWarning TEXT);");
|
||||||
|
|
||||||
|
database.execSQL("INSERT INTO TootEntity2 SELECT * FROM TootEntity;");
|
||||||
|
database.execSQL("DROP TABLE TootEntity;");
|
||||||
|
database.execSQL("ALTER TABLE TootEntity2 RENAME TO TootEntity;");
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user