Skip to content

Commit d0656ab

Browse files
authored
Add SQLite migration from version 2 to 3 (#667)
* Add migration for 2 -> 3
1 parent 8e45114 commit d0656ab

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

android/src/main/java/vn/hunghd/flutterdownloader/TaskDbHelper.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ public void onCreate(SQLiteDatabase db) {
5656

5757
@Override
5858
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
59-
db.execSQL(SQL_DELETE_ENTRIES);
60-
onCreate(db);
59+
if (oldVersion == 2 && newVersion == 3) {
60+
db.execSQL("ALTER TABLE " + TaskEntry.TABLE_NAME + " ADD COLUMN " + TaskEntry.COLUMN_SAVE_IN_PUBLIC_STORAGE + " TINYINT DEFAULT 0");
61+
} else {
62+
db.execSQL(SQL_DELETE_ENTRIES);
63+
onCreate(db);
64+
}
6165
}
6266

6367
@Override

0 commit comments

Comments
 (0)