Make sure user objects have a uuid column, include it in the migration

pull/14/head
Sam Bosley 12 years ago
parent 906fc127d4
commit 5d0fcf0dd2

@ -58,6 +58,10 @@ public final class User extends RemoteModel {
public static final LongProperty REMOTE_ID = new LongProperty( public static final LongProperty REMOTE_ID = new LongProperty(
TABLE, REMOTE_ID_PROPERTY_NAME); TABLE, REMOTE_ID_PROPERTY_NAME);
/** UUID */
public static final StringProperty UUID = new StringProperty(
TABLE, UUID_PROPERTY_NAME);
/** Pushed at date */ /** Pushed at date */
public static final LongProperty PUSHED_AT = new LongProperty( public static final LongProperty PUSHED_AT = new LongProperty(
TABLE, PUSHED_AT_PROPERTY_NAME); TABLE, PUSHED_AT_PROPERTY_NAME);
@ -84,6 +88,7 @@ public final class User extends RemoteModel {
defaultValues.put(EMAIL.name, ""); defaultValues.put(EMAIL.name, "");
defaultValues.put(PICTURE.name, ""); defaultValues.put(PICTURE.name, "");
defaultValues.put(PUSHED_AT.name, 0L); defaultValues.put(PUSHED_AT.name, 0L);
defaultValues.put(UUID.name, NO_UUID);
defaultValues.put(STATUS.name, ""); defaultValues.put(STATUS.name, "");
defaultValues.put(PENDING_STATUS.name, ""); defaultValues.put(PENDING_STATUS.name, "");
} }

@ -15,11 +15,13 @@ import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
import com.todoroo.astrid.dao.TagDataDao; import com.todoroo.astrid.dao.TagDataDao;
import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.UpdateDao; import com.todoroo.astrid.dao.UpdateDao;
import com.todoroo.astrid.dao.UserDao;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.RemoteModel; import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.Update; import com.todoroo.astrid.data.Update;
import com.todoroo.astrid.data.User;
import com.todoroo.astrid.helper.UUIDHelper; import com.todoroo.astrid.helper.UUIDHelper;
import com.todoroo.astrid.service.MetadataService; import com.todoroo.astrid.service.MetadataService;
import com.todoroo.astrid.service.TagDataService; import com.todoroo.astrid.service.TagDataService;
@ -33,6 +35,7 @@ public class AstridNewSyncMigrator {
@Autowired private TagDataDao tagDataDao; @Autowired private TagDataDao tagDataDao;
@Autowired private TaskDao taskDao; @Autowired private TaskDao taskDao;
@Autowired private UpdateDao updateDao; @Autowired private UpdateDao updateDao;
@Autowired private UserDao userDao;
private static final String PREF_SYNC_MIGRATION = "sync_migration"; 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 // Finally, ensure that all tag metadata entities have all important fields filled in

@ -372,6 +372,7 @@ public class Database extends AbstractDatabase {
database.execSQL(addColumnSql(Update.TABLE, Update.TASK_UUID, visitor, null)); database.execSQL(addColumnSql(Update.TABLE, Update.TASK_UUID, visitor, null));
database.execSQL(addColumnSql(Metadata.TABLE, Metadata.DELETION_DATE, visitor, "0")); 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.PUSHED_AT, visitor, null));
database.execSQL(addColumnSql(User.TABLE, User.UUID, visitor, null));
} catch (SQLiteException e) { } catch (SQLiteException e) {
Log.e("astrid", "db-upgrade-" + oldVersion + "-" + newVersion, e); Log.e("astrid", "db-upgrade-" + oldVersion + "-" + newVersion, e);
} }

Loading…
Cancel
Save