diff --git a/api/src/com/todoroo/astrid/data/User.java b/api/src/com/todoroo/astrid/data/User.java index 2e555503b..55ffa2e4c 100644 --- a/api/src/com/todoroo/astrid/data/User.java +++ b/api/src/com/todoroo/astrid/data/User.java @@ -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); + /** Pushed at date */ public static final LongProperty PUSHED_AT = new LongProperty( TABLE, PUSHED_AT_PROPERTY_NAME); @@ -84,6 +88,7 @@ public final class User extends RemoteModel { defaultValues.put(EMAIL.name, ""); defaultValues.put(PICTURE.name, ""); defaultValues.put(PUSHED_AT.name, 0L); + defaultValues.put(UUID.name, NO_UUID); defaultValues.put(STATUS.name, ""); defaultValues.put(PENDING_STATUS.name, ""); } diff --git a/astrid/plugin-src/com/todoroo/astrid/tags/AstridNewSyncMigrator.java b/astrid/plugin-src/com/todoroo/astrid/tags/AstridNewSyncMigrator.java index 72aa804a3..25ef67512 100644 --- a/astrid/plugin-src/com/todoroo/astrid/tags/AstridNewSyncMigrator.java +++ b/astrid/plugin-src/com/todoroo/astrid/tags/AstridNewSyncMigrator.java @@ -15,11 +15,13 @@ import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria; import com.todoroo.astrid.dao.TagDataDao; import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.UpdateDao; +import com.todoroo.astrid.dao.UserDao; import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.RemoteModel; import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Update; +import com.todoroo.astrid.data.User; import com.todoroo.astrid.helper.UUIDHelper; import com.todoroo.astrid.service.MetadataService; import com.todoroo.astrid.service.TagDataService; @@ -33,6 +35,7 @@ public class AstridNewSyncMigrator { @Autowired private TagDataDao tagDataDao; @Autowired private TaskDao taskDao; @Autowired private UpdateDao updateDao; + @Autowired private UserDao userDao; private static final String PREF_SYNC_MIGRATION = "sync_migration"; @@ -91,6 +94,10 @@ public class AstridNewSyncMigrator { } }); + userDao.deleteWhere(Criterion.or(User.REMOTE_ID.isNull(), User.REMOTE_ID.eq(0))); + Query usersQuery = Query.select(User.ID, User.REMOTE_ID).where(Criterion.all); + assertUUIDsExist(usersQuery, new User(), userDao, null); + // -------------- // Finally, ensure that all tag metadata entities have all important fields filled in diff --git a/astrid/src/com/todoroo/astrid/dao/Database.java b/astrid/src/com/todoroo/astrid/dao/Database.java index f3f0e8cc2..bf8e2bfc2 100644 --- a/astrid/src/com/todoroo/astrid/dao/Database.java +++ b/astrid/src/com/todoroo/astrid/dao/Database.java @@ -372,6 +372,7 @@ public class Database extends AbstractDatabase { database.execSQL(addColumnSql(Update.TABLE, Update.TASK_UUID, visitor, null)); database.execSQL(addColumnSql(Metadata.TABLE, Metadata.DELETION_DATE, visitor, "0")); database.execSQL(addColumnSql(User.TABLE, User.PUSHED_AT, visitor, null)); + database.execSQL(addColumnSql(User.TABLE, User.UUID, visitor, null)); } catch (SQLiteException e) { Log.e("astrid", "db-upgrade-" + oldVersion + "-" + newVersion, e); }