mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-26 02:25:50 +01:00
Port schema migration to greendao
This commit is contained in:
parent
4b374e3f7e
commit
2d2df64003
@ -29,8 +29,8 @@ import ch.qos.logback.classic.spi.ILoggingEvent;
|
|||||||
import ch.qos.logback.core.Appender;
|
import ch.qos.logback.core.Appender;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.database.DBConstants;
|
import nodomain.freeyourgadget.gadgetbridge.database.DBConstants;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.database.DBOpenHelper;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoMaster;
|
import nodomain.freeyourgadget.gadgetbridge.entities.DaoMaster;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceService;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceService;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
|
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
|
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
|
||||||
@ -203,7 +203,8 @@ public class GBApplication extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupDatabase() {
|
private void setupDatabase() {
|
||||||
DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "test-db", null);
|
// DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "test-db", null);
|
||||||
|
DBOpenHelper helper = new DBOpenHelper(this, "test-db", null);
|
||||||
SQLiteDatabase db = helper.getWritableDatabase();
|
SQLiteDatabase db = helper.getWritableDatabase();
|
||||||
DaoMaster daoMaster = new DaoMaster(db);
|
DaoMaster daoMaster = new DaoMaster(db);
|
||||||
lockHandler = new LockHandler(daoMaster.newSession());
|
lockHandler = new LockHandler(daoMaster.newSession());
|
||||||
|
@ -34,7 +34,6 @@ import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_TYPE
|
|||||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.TABLE_GBACTIVITYSAMPLES;
|
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.TABLE_GBACTIVITYSAMPLES;
|
||||||
|
|
||||||
// TODO: can be removed entirely
|
// TODO: can be removed entirely
|
||||||
// TODO: port schema migration to greendao first
|
|
||||||
public class ActivityDatabaseHandler extends SQLiteOpenHelper implements DBHandler {
|
public class ActivityDatabaseHandler extends SQLiteOpenHelper implements DBHandler {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ActivityDatabaseHandler.class);
|
private static final Logger LOG = LoggerFactory.getLogger(ActivityDatabaseHandler.class);
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
package nodomain.freeyourgadget.gadgetbridge.database;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.database.schema.SchemaMigration;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.entities.DaoMaster;
|
||||||
|
|
||||||
|
public class DBOpenHelper extends DaoMaster.OpenHelper {
|
||||||
|
public DBOpenHelper(Context context, String dbName, SQLiteDatabase.CursorFactory factory) {
|
||||||
|
super(context, dbName, factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
new SchemaMigration().onUpgrade(db, oldVersion, newVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
new SchemaMigration().onDowngrade(db, oldVersion, newVersion);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user