Dont revert when foreign key violates (#1419)
* Dont revert when foreign key violates * 1 * 2 * 3 Co-authored-by: 南宫雪珊 <vvb2060@gmail.com>
This commit is contained in:
parent
4d9f060aa9
commit
04b5a087b8
|
|
@ -79,7 +79,6 @@ import java.util.zip.ZipFile;
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
private static ConfigManager instance = null;
|
private static ConfigManager instance = null;
|
||||||
|
|
||||||
private static final int DB_VERSION = 2;
|
|
||||||
private final SQLiteDatabase db =
|
private final SQLiteDatabase db =
|
||||||
SQLiteDatabase.openOrCreateDatabase(ConfigFileManager.dbPath, null);
|
SQLiteDatabase.openOrCreateDatabase(ConfigFileManager.dbPath, null);
|
||||||
|
|
||||||
|
|
@ -325,6 +324,7 @@ public class ConfigManager {
|
||||||
values.put("apk_path", ConfigFileManager.managerApkPath.toString());
|
values.put("apk_path", ConfigFileManager.managerApkPath.toString());
|
||||||
// dummy module for config
|
// dummy module for config
|
||||||
db.insertWithOnConflict("modules", null, values, SQLiteDatabase.CONFLICT_IGNORE);
|
db.insertWithOnConflict("modules", null, values, SQLiteDatabase.CONFLICT_IGNORE);
|
||||||
|
db.setVersion(1);
|
||||||
});
|
});
|
||||||
case 1:
|
case 1:
|
||||||
executeInTransaction(() -> {
|
executeInTransaction(() -> {
|
||||||
|
|
@ -335,18 +335,32 @@ public class ConfigManager {
|
||||||
createConfigTable.execute();
|
createConfigTable.execute();
|
||||||
createScopeTable.execute();
|
createScopeTable.execute();
|
||||||
db.compileStatement("CREATE INDEX IF NOT EXISTS configs_idx ON configs (module_pkg_name, user_id);").execute();
|
db.compileStatement("CREATE INDEX IF NOT EXISTS configs_idx ON configs (module_pkg_name, user_id);").execute();
|
||||||
|
executeInTransaction(() -> {
|
||||||
|
try {
|
||||||
db.compileStatement("INSERT INTO scope SELECT * FROM old_scope;").execute();
|
db.compileStatement("INSERT INTO scope SELECT * FROM old_scope;").execute();
|
||||||
db.compileStatement("INSERT INTO configs SELECT * FROM old_configs;").execute();
|
} catch (Throwable e) {
|
||||||
|
Log.w(TAG, "migrate scope", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
executeInTransaction(() -> {
|
||||||
|
try {
|
||||||
|
executeInTransaction(() -> db.compileStatement("INSERT INTO configs SELECT * FROM old_configs;").execute());
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Log.w(TAG, "migrate config", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
db.compileStatement("DROP TABLE old_scope;").execute();
|
db.compileStatement("DROP TABLE old_scope;").execute();
|
||||||
db.compileStatement("DROP TABLE old_configs;").execute();
|
db.compileStatement("DROP TABLE old_configs;").execute();
|
||||||
|
db.setVersion(2);
|
||||||
});
|
});
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
db.setVersion(DB_VERSION);
|
} catch (
|
||||||
} catch (Throwable e) {
|
Throwable e) {
|
||||||
Log.e(TAG, "init db", e);
|
Log.e(TAG, "init db", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ProcessScope> getAssociatedProcesses(Application app) throws RemoteException {
|
private List<ProcessScope> getAssociatedProcesses(Application app) throws RemoteException {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue