From 143350fdba487388e31cba1fccaa1f3707596795 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 15 Feb 2018 12:34:56 -0800 Subject: [PATCH] Give Phriction documents modern string status constants instead of numeric constants Summary: Depends on D19099. Ref T13077. Updates Phriction documents to string constants to make API interactions cleaner and statuses more practical to extend. This does not seem to require any transaction migrations because none of the Phriction transactions actually store status values: status is always a side effect of other edits. Test Plan: Created, edited, deleted, moved documents. Saw appropriate UI cues. Browsed and filtered documents by status in the index. Maniphest Tasks: T13077 Differential Revision: https://secure.phabricator.com/D19100 --- .../autopatches/20180215.phriction.05.statustext.sql | 2 ++ .../autopatches/20180215.phriction.06.statusvalue.sql | 11 +++++++++++ .../phriction/constants/PhrictionDocumentStatus.php | 8 ++++---- .../phriction/query/PhrictionDocumentQuery.php | 2 +- .../phriction/storage/PhrictionDocument.php | 2 +- 5 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 resources/sql/autopatches/20180215.phriction.05.statustext.sql create mode 100644 resources/sql/autopatches/20180215.phriction.06.statusvalue.sql diff --git a/resources/sql/autopatches/20180215.phriction.05.statustext.sql b/resources/sql/autopatches/20180215.phriction.05.statustext.sql new file mode 100644 index 0000000000..756f7ac968 --- /dev/null +++ b/resources/sql/autopatches/20180215.phriction.05.statustext.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_phriction.phriction_document + CHANGE status status VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT}; diff --git a/resources/sql/autopatches/20180215.phriction.06.statusvalue.sql b/resources/sql/autopatches/20180215.phriction.06.statusvalue.sql new file mode 100644 index 0000000000..381de77643 --- /dev/null +++ b/resources/sql/autopatches/20180215.phriction.06.statusvalue.sql @@ -0,0 +1,11 @@ +UPDATE {$NAMESPACE}_phriction.phriction_document + SET status = 'active' WHERE status = '0'; + +UPDATE {$NAMESPACE}_phriction.phriction_document + SET status = 'deleted' WHERE status = '1'; + +UPDATE {$NAMESPACE}_phriction.phriction_document + SET status = 'moved' WHERE status = '2'; + +UPDATE {$NAMESPACE}_phriction.phriction_document + SET status = 'stub' WHERE status = '3'; diff --git a/src/applications/phriction/constants/PhrictionDocumentStatus.php b/src/applications/phriction/constants/PhrictionDocumentStatus.php index b042cd78d3..1830f3ec95 100644 --- a/src/applications/phriction/constants/PhrictionDocumentStatus.php +++ b/src/applications/phriction/constants/PhrictionDocumentStatus.php @@ -3,10 +3,10 @@ final class PhrictionDocumentStatus extends PhabricatorObjectStatus { - const STATUS_EXISTS = 0; - const STATUS_DELETED = 1; - const STATUS_MOVED = 2; - const STATUS_STUB = 3; + const STATUS_EXISTS = 'active'; + const STATUS_DELETED = 'deleted'; + const STATUS_MOVED = 'moved'; + const STATUS_STUB = 'stub'; public static function getConduitConstant($const) { static $map = array( diff --git a/src/applications/phriction/query/PhrictionDocumentQuery.php b/src/applications/phriction/query/PhrictionDocumentQuery.php index f6073b2907..de3064fd42 100644 --- a/src/applications/phriction/query/PhrictionDocumentQuery.php +++ b/src/applications/phriction/query/PhrictionDocumentQuery.php @@ -196,7 +196,7 @@ final class PhrictionDocumentQuery if ($this->statuses !== null) { $where[] = qsprintf( $conn, - 'd.status IN (%Ld)', + 'd.status IN (%Ls)', $this->statuses); } diff --git a/src/applications/phriction/storage/PhrictionDocument.php b/src/applications/phriction/storage/PhrictionDocument.php index 730b8e09bf..1942f16efe 100644 --- a/src/applications/phriction/storage/PhrictionDocument.php +++ b/src/applications/phriction/storage/PhrictionDocument.php @@ -31,7 +31,7 @@ final class PhrictionDocument extends PhrictionDAO 'slug' => 'sort128', 'depth' => 'uint32', 'contentID' => 'id?', - 'status' => 'uint32', + 'status' => 'text32', 'mailKey' => 'bytes20', ), self::CONFIG_KEY_SCHEMA => array(