Add deleted column to store table

pull/467/head
Alex Baker 9 years ago
parent f81f52dccb
commit 62013dc0fb

@ -46,7 +46,7 @@ import timber.log.Timber;
@ApplicationScope @ApplicationScope
public class Database { public class Database {
private static final int VERSION = 36; private static final int VERSION = 37;
private static final String NAME = "database"; private static final String NAME = "database";
private static final Table[] TABLES = new Table[] { private static final Table[] TABLES = new Table[] {
Task.TABLE, Task.TABLE,
@ -118,12 +118,9 @@ public class Database {
SqlConstructorVisitor visitor = new SqlConstructorVisitor(); SqlConstructorVisitor visitor = new SqlConstructorVisitor();
switch(oldVersion) { switch(oldVersion) {
case 35: case 35:
try { tryExecSQL(addColumnSql(TagData.TABLE, TagData.COLOR, visitor, "-1"));
tryExecSQL(addColumnSql(TagData.TABLE, TagData.COLOR, visitor, "-1")); case 36:
} catch (SQLiteException e) { tryExecSQL(addColumnSql(StoreObject.TABLE, StoreObject.DELETION_DATE, visitor, "0"));
tracker.reportException(e);
}
return true; return true;
} }
@ -134,7 +131,7 @@ public class Database {
try { try {
database.execSQL(sql); database.execSQL(sql);
} catch (SQLiteException e) { } catch (SQLiteException e) {
Timber.e(e, "SQL Error: %s", sql); tracker.reportException(e);
} }
} }

@ -60,6 +60,10 @@ public class StoreObject extends AbstractModel {
public static final StringProperty VALUE3 = new StringProperty( public static final StringProperty VALUE3 = new StringProperty(
TABLE, "value3"); TABLE, "value3");
/** Unixtime Task was deleted. 0 means not deleted */
public static final LongProperty DELETION_DATE = new LongProperty(
TABLE, "deleted", Property.PROP_FLAG_DATE);
/** List of all properties for this model */ /** List of all properties for this model */
public static final Property<?>[] PROPERTIES = generateProperties(StoreObject.class); public static final Property<?>[] PROPERTIES = generateProperties(StoreObject.class);
@ -68,6 +72,10 @@ public class StoreObject extends AbstractModel {
/** Default values container */ /** Default values container */
private static final ContentValues defaultValues = new ContentValues(); private static final ContentValues defaultValues = new ContentValues();
static {
defaultValues.put(DELETION_DATE.name, 0);
}
@Override @Override
public ContentValues getDefaultValues() { public ContentValues getDefaultValues() {
return defaultValues; return defaultValues;

Loading…
Cancel
Save