Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 8004fef

Browse files
committed
Add migration for older database version
1 parent 0743132 commit 8004fef

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

app/src/main/java/de/codebucket/mkkm/MobileKKM.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import android.util.Log;
2020

2121
import androidx.room.Room;
22+
import androidx.room.migration.Migration;
23+
import androidx.sqlite.db.SupportSQLiteDatabase;
2224

2325
import java.util.UUID;
2426

@@ -57,6 +59,12 @@ public void onCreate() {
5759

5860
// Init offline database (first step to native migration)
5961
database = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "appdata.db")
62+
.addMigrations(new Migration(4, 5) {
63+
@Override
64+
public void migrate(SupportSQLiteDatabase database) {
65+
database.execSQL("UPDATE tickets SET lines = '[]'");
66+
}
67+
})
6068
.fallbackToDestructiveMigration()
6169
.build();
6270

0 commit comments

Comments
 (0)