Added package table.
Required for future work which will be better able to deal with multiple repos providing the same app. Instead of migrating data into that table, we will drop and recreate the tables. This is because before this feature is out, we'll need to do that anyway.
This commit is contained in:
parent
88c536efb4
commit
5efa53b466
@ -34,6 +34,7 @@ import android.util.Log;
|
||||
import org.fdroid.fdroid.R;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
import org.fdroid.fdroid.data.Schema.ApkTable;
|
||||
import org.fdroid.fdroid.data.Schema.PackageTable;
|
||||
import org.fdroid.fdroid.data.Schema.AppPrefsTable;
|
||||
import org.fdroid.fdroid.data.Schema.AppMetadataTable;
|
||||
import org.fdroid.fdroid.data.Schema.InstalledAppTable;
|
||||
@ -50,6 +51,11 @@ class DBHelper extends SQLiteOpenHelper {
|
||||
|
||||
private static final String DATABASE_NAME = "fdroid";
|
||||
|
||||
private static final String CREATE_TABLE_PACKAGE = "CREATE TABLE " + PackageTable.NAME
|
||||
+ " ( "
|
||||
+ PackageTable.Cols.PACKAGE_NAME + " text not null"
|
||||
+ ");";
|
||||
|
||||
private static final String CREATE_TABLE_REPO = "create table "
|
||||
+ RepoTable.NAME + " ("
|
||||
+ RepoTable.Cols._ID + " integer primary key, "
|
||||
@ -146,7 +152,7 @@ class DBHelper extends SQLiteOpenHelper {
|
||||
+ " );";
|
||||
private static final String DROP_TABLE_INSTALLED_APP = "DROP TABLE " + InstalledAppTable.NAME + ";";
|
||||
|
||||
private static final int DB_VERSION = 62;
|
||||
private static final int DB_VERSION = 63;
|
||||
|
||||
private final Context context;
|
||||
|
||||
@ -248,6 +254,7 @@ class DBHelper extends SQLiteOpenHelper {
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
|
||||
db.execSQL(CREATE_TABLE_PACKAGE);
|
||||
db.execSQL(CREATE_TABLE_APP_METADATA);
|
||||
db.execSQL(CREATE_TABLE_APK);
|
||||
db.execSQL(CREATE_TABLE_INSTALLED_APP);
|
||||
@ -344,6 +351,13 @@ class DBHelper extends SQLiteOpenHelper {
|
||||
addAppPrefsTable(db, oldVersion);
|
||||
lowerCaseApkHashes(db, oldVersion);
|
||||
supportRepoPushRequests(db, oldVersion);
|
||||
migrateToPackageTable(db, oldVersion);
|
||||
}
|
||||
|
||||
private void migrateToPackageTable(SQLiteDatabase db, int oldVersion) {
|
||||
if (oldVersion < 63) {
|
||||
resetTransient(db);
|
||||
}
|
||||
}
|
||||
|
||||
private void lowerCaseApkHashes(SQLiteDatabase db, int oldVersion) {
|
||||
@ -733,8 +747,12 @@ class DBHelper extends SQLiteOpenHelper {
|
||||
|
||||
db.beginTransaction();
|
||||
try {
|
||||
if (tableExists(db, PackageTable.NAME)) {
|
||||
db.execSQL("DROP TABLE " + PackageTable.NAME);
|
||||
}
|
||||
db.execSQL("DROP TABLE " + AppMetadataTable.NAME);
|
||||
db.execSQL("DROP TABLE " + ApkTable.NAME);
|
||||
db.execSQL(CREATE_TABLE_PACKAGE);
|
||||
db.execSQL(CREATE_TABLE_APP_METADATA);
|
||||
db.execSQL(CREATE_TABLE_APK);
|
||||
clearRepoEtags(db);
|
||||
@ -765,6 +783,11 @@ class DBHelper extends SQLiteOpenHelper {
|
||||
}
|
||||
|
||||
private static void ensureIndexes(SQLiteDatabase db) {
|
||||
if (tableExists(db, PackageTable.NAME)) {
|
||||
Utils.debugLog(TAG, "Ensuring indexes exist for " + PackageTable.NAME);
|
||||
db.execSQL("CREATE INDEX IF NOT EXISTS package_packageName on " + PackageTable.NAME + " (" + PackageTable.Cols.PACKAGE_NAME + ");");
|
||||
}
|
||||
|
||||
Utils.debugLog(TAG, "Ensuring indexes exist for " + AppMetadataTable.NAME);
|
||||
db.execSQL("CREATE INDEX IF NOT EXISTS app_id on " + AppMetadataTable.NAME + " (" + AppMetadataTable.Cols.PACKAGE_NAME + ");");
|
||||
db.execSQL("CREATE INDEX IF NOT EXISTS name on " + AppMetadataTable.NAME + " (" + AppMetadataTable.Cols.NAME + ");"); // Used for sorting most lists
|
||||
|
@ -9,6 +9,20 @@ import android.provider.BaseColumns;
|
||||
*/
|
||||
public interface Schema {
|
||||
|
||||
interface PackageTable {
|
||||
|
||||
String NAME = "fdroid_package";
|
||||
|
||||
interface Cols {
|
||||
String ROW_ID = "rowid";
|
||||
String PACKAGE_NAME = "packageName";
|
||||
|
||||
String[] ALL = {
|
||||
ROW_ID, PACKAGE_NAME,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
interface AppPrefsTable {
|
||||
|
||||
String NAME = "fdroid_appPrefs";
|
||||
|
Loading…
x
Reference in New Issue
Block a user