Path: blob/master/resources/sql/autopatches/20140210.herald.rule-condition-mig.php
12250 views
<?php12$table = new HeraldCondition();3$conn_w = $table->establishConnection('w');45echo pht(6"Migrating Herald conditions of type Herald rule from IDs to PHIDs...\n");7foreach (new LiskMigrationIterator($table) as $condition) {8if ($condition->getFieldName() != HeraldAnotherRuleField::FIELDCONST) {9continue;10}1112$value = $condition->getValue();13if (!is_numeric($value)) {14continue;15}16$id = $condition->getID();17echo pht('Updating condition %s...', $id)."\n";1819$rule = id(new HeraldRuleQuery())20->setViewer(PhabricatorUser::getOmnipotentUser())21->withIDs(array($value))22->executeOne();2324queryfx(25$conn_w,26'UPDATE %T SET value = %s WHERE id = %d',27$table->getTableName(),28json_encode($rule->getPHID()),29$id);30}31echo pht('Done.')."\n";323334