Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/resources/sql/autopatches/20140210.herald.rule-condition-mig.php
12250 views
1
<?php
2
3
$table = new HeraldCondition();
4
$conn_w = $table->establishConnection('w');
5
6
echo pht(
7
"Migrating Herald conditions of type Herald rule from IDs to PHIDs...\n");
8
foreach (new LiskMigrationIterator($table) as $condition) {
9
if ($condition->getFieldName() != HeraldAnotherRuleField::FIELDCONST) {
10
continue;
11
}
12
13
$value = $condition->getValue();
14
if (!is_numeric($value)) {
15
continue;
16
}
17
$id = $condition->getID();
18
echo pht('Updating condition %s...', $id)."\n";
19
20
$rule = id(new HeraldRuleQuery())
21
->setViewer(PhabricatorUser::getOmnipotentUser())
22
->withIDs(array($value))
23
->executeOne();
24
25
queryfx(
26
$conn_w,
27
'UPDATE %T SET value = %s WHERE id = %d',
28
$table->getTableName(),
29
json_encode($rule->getPHID()),
30
$id);
31
}
32
echo pht('Done.')."\n";
33
34