Fix database migrations, drop unused columns

synthesis
Alex Baker 7 years ago
parent 084fb03a2d
commit 669e87bc3a

@ -0,0 +1,697 @@
{
"formatVersion": 1,
"database": {
"version": 53,
"identityHash": "b486099da2651e95ca41477ca52f042a",
"entities": [
{
"tableName": "notification",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uid` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `timestamp` INTEGER NOT NULL, `type` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "uid",
"columnName": "uid",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "taskId",
"columnName": "task",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "timestamp",
"columnName": "timestamp",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "type",
"columnName": "type",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"uid"
],
"autoGenerate": true
},
"indices": [
{
"name": "index_notification_task",
"unique": true,
"columnNames": [
"task"
],
"createSql": "CREATE UNIQUE INDEX `index_notification_task` ON `${TABLE_NAME}` (`task`)"
}
],
"foreignKeys": []
},
{
"tableName": "tagdata",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `remoteId` TEXT, `name` TEXT, `color` INTEGER, `tagOrdering` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "remoteId",
"columnName": "remoteId",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "color",
"columnName": "color",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "tagOrdering",
"columnName": "tagOrdering",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "userActivity",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `remoteId` TEXT, `message` TEXT, `picture` TEXT, `target_id` TEXT, `created_at` INTEGER)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "remoteId",
"columnName": "remoteId",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "message",
"columnName": "message",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "picture",
"columnName": "picture",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "targetId",
"columnName": "target_id",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "created",
"columnName": "created_at",
"affinity": "INTEGER",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "task_attachments",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `remoteId` TEXT, `task_id` TEXT, `name` TEXT, `path` TEXT, `content_type` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "remoteId",
"columnName": "remoteId",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "taskId",
"columnName": "task_id",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "path",
"columnName": "path",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "contentType",
"columnName": "content_type",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "task_list_metadata",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `remoteId` TEXT, `tag_uuid` TEXT, `filter` TEXT, `task_ids` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "remoteId",
"columnName": "remoteId",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "tagUuid",
"columnName": "tag_uuid",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "filter",
"columnName": "filter",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "taskIds",
"columnName": "task_ids",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "tasks",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `title` TEXT, `importance` INTEGER, `dueDate` INTEGER, `hideUntil` INTEGER, `created` INTEGER, `modified` INTEGER, `completed` INTEGER, `deleted` INTEGER, `notes` TEXT, `estimatedSeconds` INTEGER, `elapsedSeconds` INTEGER, `timerStart` INTEGER, `notificationFlags` INTEGER, `notifications` INTEGER, `lastNotified` INTEGER, `snoozeTime` INTEGER, `recurrence` TEXT, `repeatUntil` INTEGER, `calendarUri` TEXT, `remoteId` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "importance",
"columnName": "importance",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "dueDate",
"columnName": "dueDate",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "hideUntil",
"columnName": "hideUntil",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "created",
"columnName": "created",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "modified",
"columnName": "modified",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "completed",
"columnName": "completed",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "deleted",
"columnName": "deleted",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "notes",
"columnName": "notes",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "estimatedSeconds",
"columnName": "estimatedSeconds",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "elapsedSeconds",
"columnName": "elapsedSeconds",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "timerStart",
"columnName": "timerStart",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "notificationFlags",
"columnName": "notificationFlags",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "notifications",
"columnName": "notifications",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "lastNotified",
"columnName": "lastNotified",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "snoozeTime",
"columnName": "snoozeTime",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "recurrence",
"columnName": "recurrence",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "repeatUntil",
"columnName": "repeatUntil",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "calendarUri",
"columnName": "calendarUri",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "remoteId",
"columnName": "remoteId",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [
{
"name": "t_rid",
"unique": true,
"columnNames": [
"remoteId"
],
"createSql": "CREATE UNIQUE INDEX `t_rid` ON `${TABLE_NAME}` (`remoteId`)"
}
],
"foreignKeys": []
},
{
"tableName": "alarms",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `time` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "task",
"columnName": "task",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "time",
"columnName": "time",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "locations",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `name` TEXT, `latitude` REAL NOT NULL, `longitude` REAL NOT NULL, `radius` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "task",
"columnName": "task",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "latitude",
"columnName": "latitude",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "longitude",
"columnName": "longitude",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "radius",
"columnName": "radius",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "tags",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `name` TEXT, `tag_uid` TEXT, `task_uid` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "task",
"columnName": "task",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "tagUid",
"columnName": "tag_uid",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "taskUid",
"columnName": "task_uid",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "google_tasks",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `remote_id` TEXT, `list_id` TEXT, `parent` INTEGER NOT NULL, `indent` INTEGER NOT NULL, `order` INTEGER NOT NULL, `remote_order` INTEGER NOT NULL, `last_sync` INTEGER NOT NULL, `deleted` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "task",
"columnName": "task",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "remoteId",
"columnName": "remote_id",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "listId",
"columnName": "list_id",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "parent",
"columnName": "parent",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "indent",
"columnName": "indent",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "order",
"columnName": "order",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "remoteOrder",
"columnName": "remote_order",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "lastSync",
"columnName": "last_sync",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "deleted",
"columnName": "deleted",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "filters",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `title` TEXT, `sql` TEXT, `values` TEXT, `criterion` TEXT)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "sql",
"columnName": "sql",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "values",
"columnName": "values",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "criterion",
"columnName": "criterion",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "google_task_lists",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `remote_id` TEXT, `title` TEXT, `remote_order` INTEGER NOT NULL, `last_sync` INTEGER NOT NULL, `deleted` INTEGER NOT NULL, `color` INTEGER)",
"fields": [
{
"fieldPath": "id",
"columnName": "_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "remoteId",
"columnName": "remote_id",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "remoteOrder",
"columnName": "remote_order",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "lastSync",
"columnName": "last_sync",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "deleted",
"columnName": "deleted",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "color",
"columnName": "color",
"affinity": "INTEGER",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"_id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
}
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"b486099da2651e95ca41477ca52f042a\")"
]
}
}

@ -176,8 +176,7 @@ public final class TaskEditFragment extends InjectingFragment implements Toolbar
getString(R.string.TEA_timer_comment_stopped), getString(R.string.TEA_timer_comment_stopped),
DateUtilities.getTimeString(getActivity(), newDateTime()), DateUtilities.getTimeString(getActivity(), newDateTime()),
getString(R.string.TEA_timer_comment_spent), getString(R.string.TEA_timer_comment_spent),
elapsedTime), UserActivity.ACTION_TASK_COMMENT, elapsedTime), null);
null);
return model; return model;
} }
@ -186,7 +185,6 @@ public final class TaskEditFragment extends InjectingFragment implements Toolbar
addComment(String.format("%s %s", addComment(String.format("%s %s",
getString(R.string.TEA_timer_comment_started), getString(R.string.TEA_timer_comment_started),
DateUtilities.getTimeString(getActivity(), newDateTime())), DateUtilities.getTimeString(getActivity(), newDateTime())),
UserActivity.ACTION_TASK_COMMENT,
null); null);
return model; return model;
} }
@ -320,10 +318,9 @@ public final class TaskEditFragment extends InjectingFragment implements Toolbar
} }
} }
public void addComment(String message, String actionCode, String picture) { public void addComment(String message, String picture) {
UserActivity userActivity = new UserActivity(); UserActivity userActivity = new UserActivity();
userActivity.setMessage(message); userActivity.setMessage(message);
userActivity.setAction(actionCode);
userActivity.setTargetId(model.getUuid()); userActivity.setTargetId(model.getUuid());
userActivity.setCreated(DateUtilities.now()); userActivity.setCreated(DateUtilities.now());
if (picture != null) { if (picture != null) {

@ -456,10 +456,10 @@ public class TaskListActivity extends InjectingAppCompatActivity implements
} }
@Override @Override
public void addComment(String message, String actionCode, String picture) { public void addComment(String message, String picture) {
TaskEditFragment taskEditFragment = getTaskEditFragment(); TaskEditFragment taskEditFragment = getTaskEditFragment();
if (taskEditFragment != null) { if (taskEditFragment != null) {
taskEditFragment.addComment(message, actionCode, picture); taskEditFragment.addComment(message, picture);
} }
} }

@ -59,7 +59,7 @@ import timber.log.Timber;
Filter.class, Filter.class,
GoogleTaskList.class GoogleTaskList.class
}, },
version = 52) version = 53)
public abstract class Database extends RoomDatabase { public abstract class Database extends RoomDatabase {
public abstract NotificationDao notificationDao(); public abstract NotificationDao notificationDao();

@ -31,10 +31,6 @@ public final class TagData implements Parcelable {
@ColumnInfo(name = "tagOrdering") @ColumnInfo(name = "tagOrdering")
private String tagOrdering = "[]"; private String tagOrdering = "[]";
@Deprecated
@ColumnInfo(name = "deleted")
private Long deleted = 0L;
public TagData() { public TagData() {
} }
@ -44,7 +40,6 @@ public final class TagData implements Parcelable {
reader.readString("name", this::setName); reader.readString("name", this::setName);
reader.readInteger("color", this::setColor); reader.readInteger("color", this::setColor);
reader.readString("tagOrdering", this::setTagOrdering); reader.readString("tagOrdering", this::setTagOrdering);
reader.readLong("deleted", this::setDeleted);
} }
@Ignore @Ignore
@ -54,7 +49,6 @@ public final class TagData implements Parcelable {
name = parcel.readString(); name = parcel.readString();
color = parcel.readInt(); color = parcel.readInt();
tagOrdering = parcel.readString(); tagOrdering = parcel.readString();
deleted = parcel.readLong();
} }
public void writeToXml(XmlWriter writer) { public void writeToXml(XmlWriter writer) {
@ -62,7 +56,6 @@ public final class TagData implements Parcelable {
writer.writeString("name", name); writer.writeString("name", name);
writer.writeInteger("color", color); writer.writeInteger("color", color);
writer.writeString("tagOrdering", tagOrdering); writer.writeString("tagOrdering", tagOrdering);
writer.writeLong("deleted", deleted);
} }
public Long getId() { public Long getId() {
@ -105,14 +98,6 @@ public final class TagData implements Parcelable {
this.color = color; this.color = color;
} }
public Long getDeleted() {
return deleted;
}
public void setDeleted(long deleted) {
this.deleted = deleted;
}
public static final Creator<TagData> CREATOR = new Creator<TagData>() { public static final Creator<TagData> CREATOR = new Creator<TagData>() {
@Override @Override
public TagData createFromParcel(Parcel source) { public TagData createFromParcel(Parcel source) {
@ -137,7 +122,6 @@ public final class TagData implements Parcelable {
dest.writeString(name); dest.writeString(name);
dest.writeInt(color); dest.writeInt(color);
dest.writeString(tagOrdering); dest.writeString(tagOrdering);
dest.writeLong(deleted);
} }
@Override @Override
@ -152,9 +136,7 @@ public final class TagData implements Parcelable {
return false; return false;
if (name != null ? !name.equals(tagData.name) : tagData.name != null) return false; if (name != null ? !name.equals(tagData.name) : tagData.name != null) return false;
if (color != null ? !color.equals(tagData.color) : tagData.color != null) return false; if (color != null ? !color.equals(tagData.color) : tagData.color != null) return false;
if (tagOrdering != null ? !tagOrdering.equals(tagData.tagOrdering) : tagData.tagOrdering != null) return tagOrdering != null ? tagOrdering.equals(tagData.tagOrdering) : tagData.tagOrdering == null;
return false;
return deleted != null ? deleted.equals(tagData.deleted) : tagData.deleted == null;
} }
@Override @Override
@ -164,7 +146,6 @@ public final class TagData implements Parcelable {
result = 31 * result + (name != null ? name.hashCode() : 0); result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (color != null ? color.hashCode() : 0); result = 31 * result + (color != null ? color.hashCode() : 0);
result = 31 * result + (tagOrdering != null ? tagOrdering.hashCode() : 0); result = 31 * result + (tagOrdering != null ? tagOrdering.hashCode() : 0);
result = 31 * result + (deleted != null ? deleted.hashCode() : 0);
return result; return result;
} }
@ -176,7 +157,6 @@ public final class TagData implements Parcelable {
", name='" + name + '\'' + ", name='" + name + '\'' +
", color=" + color + ", color=" + color +
", tagOrdering='" + tagOrdering + '\'' + ", tagOrdering='" + tagOrdering + '\'' +
", deleted=" + deleted +
'}'; '}';
} }
} }

@ -17,13 +17,13 @@ public abstract class TagDataDao {
public abstract TagData getTagByName(String name); public abstract TagData getTagByName(String name);
// TODO: does this need to be ordered? // TODO: does this need to be ordered?
@Query("SELECT * FROM tagdata WHERE deleted = 0 ORDER BY _id ASC") @Query("SELECT * FROM tagdata ORDER BY _id ASC")
public abstract List<TagData> allTags(); public abstract List<TagData> allTags();
@Query("SELECT * FROM tagdata WHERE remoteId = :uuid LIMIT 1") @Query("SELECT * FROM tagdata WHERE remoteId = :uuid LIMIT 1")
public abstract TagData getByUuid(String uuid); public abstract TagData getByUuid(String uuid);
@Query("SELECT * FROM tagdata WHERE deleted = 0 AND name IS NOT NULL ORDER BY UPPER(name) ASC") @Query("SELECT * FROM tagdata WHERE name IS NOT NULL ORDER BY UPPER(name) ASC")
public abstract List<TagData> tagDataOrderedByName(); public abstract List<TagData> tagDataOrderedByName();
@Insert(onConflict = OnConflictStrategy.REPLACE) @Insert(onConflict = OnConflictStrategy.REPLACE)

@ -38,9 +38,6 @@ public final class TaskAttachment {
@ColumnInfo(name = "content_type") @ColumnInfo(name = "content_type")
private String contentType = ""; private String contentType = "";
@ColumnInfo(name = "deleted_at")
private Long deleted = 0L;
// -- Constants // -- Constants
/** default directory for files on external storage */ /** default directory for files on external storage */
public static final String FILES_DIRECTORY_DEFAULT = "attachments"; //$NON-NLS-1$ public static final String FILES_DIRECTORY_DEFAULT = "attachments"; //$NON-NLS-1$
@ -57,7 +54,6 @@ public final class TaskAttachment {
attachment.setName(fileName); attachment.setName(fileName);
attachment.setPath(filePath); attachment.setPath(filePath);
attachment.setContentType(fileType); attachment.setContentType(fileType);
attachment.setDeleted(0L);
return attachment; return attachment;
} }
@ -108,12 +104,4 @@ public final class TaskAttachment {
public void setContentType(String contentType) { public void setContentType(String contentType) {
this.contentType = contentType; this.contentType = contentType;
} }
public Long getDeleted() {
return deleted;
}
public void setDeleted(Long deleted) {
this.deleted = deleted;
}
} }

@ -15,7 +15,7 @@ import java.util.List;
@Dao @Dao
public abstract class TaskAttachmentDao { public abstract class TaskAttachmentDao {
@Query("SELECT * FROM task_attachments WHERE task_id = :taskUuid AND deleted_at = 0") @Query("SELECT * FROM task_attachments WHERE task_id = :taskUuid")
public abstract List<TaskAttachment> getAttachments(String taskUuid); public abstract List<TaskAttachment> getAttachments(String taskUuid);
@Delete @Delete

@ -22,8 +22,6 @@ import timber.log.Timber;
@Entity(tableName = "userActivity") @Entity(tableName = "userActivity")
public class UserActivity implements Parcelable { public class UserActivity implements Parcelable {
public static final String ACTION_TASK_COMMENT = "task_comment";
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "_id") @ColumnInfo(name = "_id")
private Long id; private Long id;
@ -31,9 +29,6 @@ public class UserActivity implements Parcelable {
@ColumnInfo(name = "remoteId") @ColumnInfo(name = "remoteId")
private String remoteId = Task.NO_UUID; private String remoteId = Task.NO_UUID;
@ColumnInfo(name = "action")
private String action = "";
@ColumnInfo(name = "message") @ColumnInfo(name = "message")
private String message = ""; private String message = "";
@ -46,43 +41,34 @@ public class UserActivity implements Parcelable {
@ColumnInfo(name = "created_at") @ColumnInfo(name = "created_at")
private Long created = 0L; private Long created = 0L;
@ColumnInfo(name = "deleted_at")
private Long deleted = 0L;
public UserActivity() { public UserActivity() {
} }
@Ignore @Ignore
public UserActivity(XmlReader reader) { public UserActivity(XmlReader reader) {
reader.readString("remoteId", this::setRemoteId); reader.readString("remoteId", this::setRemoteId);
reader.readString("action", this::setAction);
reader.readString("message", this::setMessage); reader.readString("message", this::setMessage);
reader.readString("picture", this::setPicture); reader.readString("picture", this::setPicture);
reader.readString("target_id", this::setTargetId); reader.readString("target_id", this::setTargetId);
reader.readLong("created_at", this::setCreated); reader.readLong("created_at", this::setCreated);
reader.readLong("deleted_at", this::setDeleted);
} }
@Ignore @Ignore
private UserActivity(Parcel parcel) { private UserActivity(Parcel parcel) {
id = parcel.readLong(); id = parcel.readLong();
remoteId = parcel.readString(); remoteId = parcel.readString();
action = parcel.readString();
message = parcel.readString(); message = parcel.readString();
picture = parcel.readString(); picture = parcel.readString();
targetId = parcel.readString(); targetId = parcel.readString();
created = parcel.readLong(); created = parcel.readLong();
deleted = parcel.readLong();
} }
public void writeToXml(XmlWriter writer) { public void writeToXml(XmlWriter writer) {
writer.writeString("remoteId", remoteId); writer.writeString("remoteId", remoteId);
writer.writeString("action", action);
writer.writeString("message", message); writer.writeString("message", message);
writer.writeString("picture", picture); writer.writeString("picture", picture);
writer.writeString("target_id", targetId); writer.writeString("target_id", targetId);
writer.writeLong("created_at", created); writer.writeLong("created_at", created);
writer.writeLong("deleted_at", deleted);
} }
public Long getId() { public Long getId() {
@ -101,14 +87,6 @@ public class UserActivity implements Parcelable {
this.remoteId = remoteId; this.remoteId = remoteId;
} }
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public String getMessage() { public String getMessage() {
return message; return message;
} }
@ -141,14 +119,6 @@ public class UserActivity implements Parcelable {
this.created = created; this.created = created;
} }
public Long getDeleted() {
return deleted;
}
public void setDeleted(Long deleted) {
this.deleted = deleted;
}
public Uri getPictureUri() { public Uri getPictureUri() {
return getPictureUri(picture); return getPictureUri(picture);
} }
@ -174,12 +144,10 @@ public class UserActivity implements Parcelable {
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id); dest.writeLong(id);
dest.writeString(remoteId); dest.writeString(remoteId);
dest.writeString(action);
dest.writeString(message); dest.writeString(message);
dest.writeString(picture); dest.writeString(picture);
dest.writeString(targetId); dest.writeString(targetId);
dest.writeLong(created); dest.writeLong(created);
dest.writeLong(deleted);
} }
private static Uri getPictureUri(String value) { private static Uri getPictureUri(String value) {

@ -16,7 +16,7 @@ public abstract class UserActivityDao {
@Insert @Insert
public abstract void insert(UserActivity userActivity); public abstract void insert(UserActivity userActivity);
@Query("SELECT * FROM userActivity WHERE `action` = 'task_comment' AND target_id = :taskUuid AND deleted_at = 0 ORDER BY created_at DESC ") @Query("SELECT * FROM userActivity WHERE target_id = :taskUuid ORDER BY created_at DESC ")
public abstract List<UserActivity> getCommentsForTask(String taskUuid); public abstract List<UserActivity> getCommentsForTask(String taskUuid);
public void createNew(UserActivity item) { public void createNew(UserActivity item) {

@ -2,8 +2,11 @@ package org.tasks.db;
import android.arch.persistence.db.SupportSQLiteDatabase; import android.arch.persistence.db.SupportSQLiteDatabase;
import android.arch.persistence.room.migration.Migration; import android.arch.persistence.room.migration.Migration;
import android.database.sqlite.SQLiteException;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import timber.log.Timber;
public class Migrations { public class Migrations {
private static final Migration MIGRATION_35_36 = new Migration(35, 36) { private static final Migration MIGRATION_35_36 = new Migration(35, 36) {
@Override @Override
@ -22,7 +25,23 @@ public class Migrations {
private static final Migration MIGRATION_37_38 = new Migration(37, 38) { private static final Migration MIGRATION_37_38 = new Migration(37, 38) {
@Override @Override
public void migrate(@NonNull SupportSQLiteDatabase database) { public void migrate(@NonNull SupportSQLiteDatabase database) {
try {
database.execSQL("ALTER TABLE `store` ADD COLUMN `value4` TEXT DEFAULT -1"); database.execSQL("ALTER TABLE `store` ADD COLUMN `value4` TEXT DEFAULT -1");
} catch (SQLiteException e) {
Timber.w(e, e.getMessage());
}
database.execSQL("ALTER TABLE `task_list_metadata` RENAME TO `task_list_metadata-temp`");
database.execSQL("CREATE TABLE `task_list_metadata` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `remoteId` TEXT, `tag_uuid` TEXT, `filter` TEXT, `task_ids` TEXT)");
database.execSQL("INSERT INTO `task_list_metadata` (`remoteId`, `tag_uuid`, `filter`, `task_ids`) " +
"SELECT `remoteId`, `tag_uuid`, `filter`, `task_ids` FROM `task_list_metadata-temp`");
database.execSQL("DROP TABLE `task_list_metadata-temp`");
database.execSQL("ALTER TABLE `tasks` RENAME TO `tasks-temp`");
database.execSQL("CREATE TABLE `tasks` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `title` TEXT, `importance` INTEGER, `dueDate` INTEGER, `hideUntil` INTEGER, `created` INTEGER, `modified` INTEGER, `completed` INTEGER, `deleted` INTEGER, `notes` TEXT, `estimatedSeconds` INTEGER, `elapsedSeconds` INTEGER, `timerStart` INTEGER, `notificationFlags` INTEGER, `notifications` INTEGER, `lastNotified` INTEGER, `snoozeTime` INTEGER, `recurrence` TEXT, `repeatUntil` INTEGER, `calendarUri` TEXT, `remoteId` TEXT)");
database.execSQL("INSERT INTO `tasks` (`title`, `importance`, `dueDate`, `hideUntil`, `created`, `modified`, `completed`, `deleted`, `notes`, `estimatedSeconds`, `elapsedSeconds`, `timerStart`, `notificationFlags`, `notifications`, `lastNotified`, `snoozeTime`, `recurrence`, `repeatUntil`, `calendarUri`, `remoteId`) " +
"SELECT `title`, `importance`, `dueDate`, `hideUntil`, `created`, `modified`, `completed`, `deleted`, `notes`, `estimatedSeconds`, `elapsedSeconds`, `timerStart`, `notificationFlags`, `notifications`, `lastNotified`, `snoozeTime`, `recurrence`, `repeatUntil`, `calendarUri`, `remoteId` FROM `tasks-temp`");
database.execSQL("DROP TABLE `tasks-temp`");
} }
}; };
@ -37,7 +56,7 @@ public class Migrations {
private static final Migration MIGRATION_46_47 = new Migration(46, 47) { private static final Migration MIGRATION_46_47 = new Migration(46, 47) {
@Override @Override
public void migrate(@NonNull SupportSQLiteDatabase database) { public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("CREATE TABLE IF NOT EXISTS `alarms` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `task` INTEGER, `time` INTEGER)"); database.execSQL("CREATE TABLE IF NOT EXISTS `alarms` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task` INTEGER NOT NULL, `time` INTEGER NOT NULL)");
database.execSQL("INSERT INTO `alarms` (`task`, `time`) SELECT `task`, `value` FROM `metadata` WHERE `key` = 'alarm' AND `deleted` = 0"); database.execSQL("INSERT INTO `alarms` (`task`, `time`) SELECT `task`, `value` FROM `metadata` WHERE `key` = 'alarm' AND `deleted` = 0");
database.execSQL("DELETE FROM `metadata` WHERE `key` = 'alarm'"); database.execSQL("DELETE FROM `metadata` WHERE `key` = 'alarm'");
} }
@ -93,6 +112,29 @@ public class Migrations {
} }
}; };
private static final Migration MIGRATION_52_53 = new Migration(52, 53) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE `tagdata` RENAME TO `tagdata-temp`");
database.execSQL("CREATE TABLE `tagdata` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `remoteId` TEXT, `name` TEXT, `color` INTEGER, `tagOrdering` TEXT)");
database.execSQL("INSERT INTO `tagdata` (`remoteId`, `name`, `color`, `tagOrdering`) " +
"SELECT `remoteId`, `name`, `color`, `tagOrdering` FROM `tagdata-temp`");
database.execSQL("DROP TABLE `tagdata-temp`");
database.execSQL("ALTER TABLE `userActivity` RENAME TO `userActivity-temp`");
database.execSQL("CREATE TABLE `userActivity` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `remoteId` TEXT, `message` TEXT, `picture` TEXT, `target_id` TEXT, `created_at` INTEGER)");
database.execSQL("INSERT INTO `userActivity` (`remoteId`, `message`, `picture`, `target_id`, `created_at`) " +
"SELECT `remoteId`, `message`, `picture`, `target_id`, `created_at` FROM `userActivity-temp`");
database.execSQL("DROP TABLE `userActivity-temp`");
database.execSQL("ALTER TABLE `task_attachments` RENAME TO `task_attachments-temp`");
database.execSQL("CREATE TABLE `task_attachments` (`_id` INTEGER PRIMARY KEY AUTOINCREMENT, `remoteId` TEXT, `task_id` TEXT, `name` TEXT, `path` TEXT, `content_type` TEXT)");
database.execSQL("INSERT INTO `task_attachments` (`remoteId`, `task_id`, `name`, `path`, `content_type`) " +
"SELECT `remoteId`, `task_id`, `name`, `path`, `content_type` FROM `task_attachments-temp`");
database.execSQL("DROP TABLE `task_attachments-temp`");
}
};
private static Migration NOOP(int from, int to) { private static Migration NOOP(int from, int to) {
return new Migration(from, to) { return new Migration(from, to) {
@Override @Override
@ -113,6 +155,7 @@ public class Migrations {
MIGRATION_48_49, MIGRATION_48_49,
MIGRATION_49_50, MIGRATION_49_50,
MIGRATION_50_51, MIGRATION_50_51,
MIGRATION_51_52 MIGRATION_51_52,
MIGRATION_52_53
}; };
} }

@ -56,7 +56,7 @@ public class CommentBarFragment extends TaskEditControlFragment {
public static final int TAG = R.string.TEA_ctrl_comments; public static final int TAG = R.string.TEA_ctrl_comments;
public interface CommentBarFragmentCallback { public interface CommentBarFragmentCallback {
void addComment(String message, String actionCode, String picture); void addComment(String message, String picture);
} }
public interface ClearImageCallback { public interface ClearImageCallback {
@ -199,7 +199,7 @@ public class CommentBarFragment extends TaskEditControlFragment {
} }
private void addComment() { private void addComment() {
addComment(commentField.getText().toString(), UserActivity.ACTION_TASK_COMMENT); addComment(commentField.getText().toString());
AndroidUtilities.hideSoftInputForViews(activity, commentField); AndroidUtilities.hideSoftInputForViews(activity, commentField);
} }
@ -210,7 +210,7 @@ public class CommentBarFragment extends TaskEditControlFragment {
commentButton.setVisibility(View.VISIBLE); commentButton.setVisibility(View.VISIBLE);
} }
private void addComment(String message, String actionCode) { private void addComment(String message) {
// Allow for users to just add picture // Allow for users to just add picture
if (TextUtils.isEmpty(message)) { if (TextUtils.isEmpty(message)) {
message = " "; message = " ";
@ -229,7 +229,7 @@ public class CommentBarFragment extends TaskEditControlFragment {
pendingCommentPicture = null; pendingCommentPicture = null;
resetPictureButton(); resetPictureButton();
callback.addComment(message, actionCode, picture); callback.addComment(message, picture);
} }
private static JSONObject savePictureJson(final Uri uri) { private static JSONObject savePictureJson(final Uri uri) {

Loading…
Cancel
Save