Use string constants, not integer constants, to represent task status internally

Summary:
Ref T1812. I think integer constants are going to be confusing and error prone for users to interact with. For example, because we use 0-5, adding a second "open" status like "needs verification" without disrupting the existing statuses would require users to define a status with, e.g., constant `6`, but order it between constants `0` and `1`. And if they later remove statuses, they need to avoid reusing existing constants.

Instead, use more manageable string constants like "open", "resolved", etc.

We must migrate three tables:

  - The task table itself, to update task status.
  - The transaction table, to update historic status changes.
  - The saved query table, to update saved queries which specify status sets.

Test Plan:
  - Saved a query with complicated status filters.
  - Ran migrations.
  - Looked at the query, at existing tasks, and at task transactions.
  - Forced migrations to run again to verify idempotentcy/safety.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T1812

Differential Revision: https://secure.phabricator.com/D8583
This commit is contained in:
epriestley
2014-03-25 13:58:14 -07:00
parent 47d6d0bbad
commit 0a76d82a7c
6 changed files with 110 additions and 15 deletions

View File

@@ -351,12 +351,12 @@ final class ManiphestTaskQuery
case self::STATUS_OPEN:
return qsprintf(
$conn,
'status IN (%Ld)',
'status IN (%Ls)',
ManiphestTaskStatus::getOpenStatusConstants());
case self::STATUS_CLOSED:
return qsprintf(
$conn,
'status IN (%Ld)',
'status IN (%Ls)',
ManiphestTaskStatus::getClosedStatusConstants());
default:
$constant = idx($map, $this->status);
@@ -365,7 +365,7 @@ final class ManiphestTaskQuery
}
return qsprintf(
$conn,
'status = %d',
'status = %s',
$constant);
}
}
@@ -374,7 +374,7 @@ final class ManiphestTaskQuery
if ($this->statuses) {
return qsprintf(
$conn,
'status IN (%Ld)',
'status IN (%Ls)',
$this->statuses);
}
return null;
@@ -826,8 +826,8 @@ final class ManiphestTaskQuery
case self::GROUP_STATUS:
$columns[] = array(
'name' => 'task.status',
'value' => (int)$group_id,
'type' => 'int',
'value' => $group_id,
'type' => 'string',
);
break;
case self::GROUP_PROJECT: