mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Add DB updaters for Category table
This commit is contained in:
parent
8b7095042d
commit
79f6185f8c
3 changed files with 19 additions and 1 deletions
|
|
@ -127,6 +127,16 @@ public class Category {
|
|||
if(from == to) {
|
||||
return;
|
||||
}
|
||||
if(from < 4) {
|
||||
// doesn't exist yet
|
||||
from++;
|
||||
onUpdate(db, from, to);
|
||||
return;
|
||||
}
|
||||
if(from == 4) {
|
||||
// table added in version 5
|
||||
onCreate(db);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -302,6 +302,11 @@ public class Contribution extends Media {
|
|||
from++;
|
||||
return;
|
||||
}
|
||||
if(from == 4) {
|
||||
// Do nothing -- added Category
|
||||
from++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,13 +3,14 @@ package org.wikimedia.commons.data;
|
|||
import android.content.*;
|
||||
import android.database.sqlite.*;
|
||||
|
||||
import org.wikimedia.commons.category.Category;
|
||||
import org.wikimedia.commons.contributions.*;
|
||||
import org.wikimedia.commons.modifications.ModifierSequence;
|
||||
|
||||
public class DBOpenHelper extends SQLiteOpenHelper{
|
||||
|
||||
private static final String DATABASE_NAME = "commons.db";
|
||||
private static final int DATABASE_VERSION = 4;
|
||||
private static final int DATABASE_VERSION = 5;
|
||||
|
||||
public DBOpenHelper(Context context) {
|
||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||
|
|
@ -19,11 +20,13 @@ public class DBOpenHelper extends SQLiteOpenHelper{
|
|||
public void onCreate(SQLiteDatabase sqLiteDatabase) {
|
||||
Contribution.Table.onCreate(sqLiteDatabase);
|
||||
ModifierSequence.Table.onCreate(sqLiteDatabase);
|
||||
Category.Table.onCreate(sqLiteDatabase);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int from, int to) {
|
||||
Contribution.Table.onUpdate(sqLiteDatabase, from, to);
|
||||
ModifierSequence.Table.onUpdate(sqLiteDatabase, from, to);
|
||||
Category.Table.onUpdate(sqLiteDatabase, from, to);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue