Add uuid column to remote model database entities

pull/14/head
Sam Bosley 12 years ago
parent def1a55d9d
commit 8120cd22c8

@ -35,4 +35,11 @@ abstract public class RemoteModel extends AbstractModel {
/** user json property */
public static final StringProperty USER_JSON_PROPERTY = new StringProperty(null, USER_JSON_PROPERTY_NAME);
/** uuid property name */
public static final String UUID_PROPERTY_NAME = "uuid"; //$NON-NLS-1$
/** uuid property */
public static final StringProperty UUID_PROPERTY = new StringProperty(null, UUID_PROPERTY_NAME);
}

@ -114,6 +114,10 @@ public final class TagData extends RemoteModel {
public static final StringProperty TAG_DESCRIPTION = new StringProperty(
TABLE, "tagDescription");
/** uuid */
public static final StringProperty UUID = new StringProperty(
TABLE, UUID_PROPERTY_NAME);
/** List of all properties for this model */
public static final Property<?>[] PROPERTIES = generateProperties(TagData.class);

@ -134,6 +134,10 @@ public final class Task extends RemoteModel {
public static final StringProperty CALENDAR_URI = new StringProperty(
TABLE, "calendarUri");
/** uuid */
public static final StringProperty UUID = new StringProperty(
TABLE, UUID_PROPERTY_NAME);
// --- for astrid.com
/** Remote id */

@ -101,6 +101,10 @@ public class Update extends RemoteModel {
public static final LongProperty CREATION_DATE = new LongProperty(
TABLE, "created");
/** uuid */
public static final StringProperty UUID = new StringProperty(
TABLE, UUID_PROPERTY_NAME);
/** List of all properties for this model */
public static final Property<?>[] PROPERTIES = generateProperties(Update.class);

@ -58,6 +58,10 @@ public final class User extends RemoteModel {
public static final LongProperty REMOTE_ID = new LongProperty(
TABLE, REMOTE_ID_PROPERTY_NAME);
/** uuid */
public static final StringProperty UUID = new StringProperty(
TABLE, UUID_PROPERTY_NAME);
/** List of all properties for this model */
public static final Property<?>[] PROPERTIES = generateProperties(User.class);

@ -337,6 +337,11 @@ public class Database extends AbstractDatabase {
case 25: try {
database.execSQL(createTableSql(visitor, TaskOutstanding.TABLE.name, TaskOutstanding.PROPERTIES));
database.execSQL(createTableSql(visitor, TagOutstanding.TABLE.name, TagOutstanding.PROPERTIES));
database.execSQL(addColumnSql(TagData.TABLE, TagData.UUID, visitor));
database.execSQL(addColumnSql(Task.TABLE, Task.UUID, visitor));
database.execSQL(addColumnSql(Update.TABLE, Update.UUID, visitor));
database.execSQL(addColumnSql(User.TABLE, User.UUID, visitor));
} catch (SQLiteException e) {
Log.e("astrid", "db-upgrade-" + oldVersion + "-" + newVersion, e);
}
@ -347,6 +352,10 @@ public class Database extends AbstractDatabase {
return false;
}
private String addColumnSql(Table table, Property<?> column, SqlConstructorVisitor visitor) {
return "ALTER TABLE " + table.name + " ADD " + column.accept(visitor, null);
}
/**
* Create table generation SQL
* @param sql

Loading…
Cancel
Save