Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15407889
D18927.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D18927.diff
View Options
diff --git a/resources/sql/autopatches/20180124.herald.01.repetition.sql b/resources/sql/autopatches/20180124.herald.01.repetition.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20180124.herald.01.repetition.sql
@@ -0,0 +1,22 @@
+/* This column was previously "uint32?" with these values:
+
+ 1: run every time
+ 0: run only the first time
+
+*/
+
+ALTER TABLE {$NAMESPACE}_herald.herald_rule
+ CHANGE repetitionPolicy
+ repetitionPolicy VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT};
+
+/* If the old value was "0", the new value is "first". */
+
+UPDATE {$NAMESPACE}_herald.herald_rule
+ SET repetitionPolicy = 'first'
+ WHERE repetitionPolicy = '0';
+
+/* If the old value was anything else, the new value is "every". */
+
+UPDATE {$NAMESPACE}_herald.herald_rule
+ SET repetitionPolicy = 'every'
+ WHERE repetitionPolicy NOT IN ('first', '0');
diff --git a/src/applications/herald/storage/HeraldRule.php b/src/applications/herald/storage/HeraldRule.php
--- a/src/applications/herald/storage/HeraldRule.php
+++ b/src/applications/herald/storage/HeraldRule.php
@@ -41,13 +41,10 @@
'contentType' => 'text255',
'mustMatchAll' => 'bool',
'configVersion' => 'uint32',
+ 'repetitionPolicy' => 'text32',
'ruleType' => 'text32',
'isDisabled' => 'uint32',
'triggerObjectPHID' => 'phid?',
-
- // T6203/NULLABILITY
- // This should not be nullable.
- 'repetitionPolicy' => 'uint32?',
),
self::CONFIG_KEY_SCHEMA => array(
'key_name' => array(
@@ -261,27 +258,11 @@
public function getRepetitionPolicyStringConstant() {
- $map = self::getRepetitionPolicyMap();
- $map = ipull($map, 'key.string', 'key.int');
-
- return idx($map, $this->getRepetitionPolicyIntegerConstant());
- }
-
- public function getRepetitionPolicyIntegerConstant() {
- $map = self::getRepetitionPolicyMap();
- $map = ipull($map, 'key.int', 'key.int');
- $int = $this->getRepetitionPolicy();
-
- if (!isset($map[$int])) {
- return head_key($map);
- }
-
- return $int;
+ return $this->getRepetitionPolicy();
}
public function setRepetitionPolicyStringConstant($value) {
$map = self::getRepetitionPolicyMap();
- $map = ipull($map, 'key.int', 'key.string');
if (!isset($map[$value])) {
throw new Exception(
@@ -290,9 +271,7 @@
$value));
}
- $int = $map[$value];
-
- return $this->setRepetitionPolicy($int);
+ return $this->setRepetitionPolicy($value);
}
public function isRepeatEvery() {
@@ -305,20 +284,15 @@
public static function getRepetitionPolicySelectOptionMap() {
$map = self::getRepetitionPolicyMap();
- $map = ipull($map, 'select', 'key.string');
- return $map;
+ return ipull($map, 'select');
}
private static function getRepetitionPolicyMap() {
return array(
self::REPEAT_EVERY => array(
- 'key.int' => 1,
- 'key.string' => self::REPEAT_EVERY,
'select' => pht('every time'),
),
self::REPEAT_FIRST => array(
- 'key.int' => 0,
- 'key.string' => self::REPEAT_FIRST,
'select' => pht('only the first time'),
),
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 19, 8:04 PM (4 d, 15 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7703533
Default Alt Text
D18927.diff (3 KB)
Attached To
Mode
D18927: Convert storage for Herald repetition policy to "text32"
Attached
Detach File
Event Timeline
Log In to Comment