mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-12 00:26:13 +01:00
b3e196b694
Summary: Ref T5655. Fixes T6849. This is another take on D11131, which was missing the DB migration and was reverted in rP7c4de0f6be77ddaea593e1f41ae27211ec179a55. Test Plan: Ran `./bin/storage upgrade` and verified that the classes were renamed in the `phabricator_policy.policy` table. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T6849, T5655 Differential Revision: https://secure.phabricator.com/D11166
38 lines
838 B
PHP
38 lines
838 B
PHP
<?php
|
|
|
|
$policies = array(
|
|
'Administrators',
|
|
'LegalpadSignature',
|
|
'LunarPhase',
|
|
'Projects',
|
|
'Users',
|
|
);
|
|
$map = array();
|
|
|
|
foreach ($policies as $policy) {
|
|
$old_name = "PhabricatorPolicyRule{$policy}";
|
|
$new_name = "Phabricator{$policy}PolicyRule";
|
|
$map[$old_name] = $new_name;
|
|
}
|
|
|
|
echo "Migrating policies...\n";
|
|
$table = new PhabricatorPolicy();
|
|
$conn_w = $table->establishConnection('w');
|
|
|
|
foreach (new LiskMigrationIterator($table) as $policy) {
|
|
$old_rules = $policy->getRules();
|
|
$new_rules = array();
|
|
|
|
foreach ($old_rules as $rule) {
|
|
$existing_rule = $rule['rule'];
|
|
$rule['rule'] = idx($map, $existing_rule, $existing_rule);
|
|
$new_rules[] = $rule;
|
|
}
|
|
|
|
queryfx(
|
|
$conn_w,
|
|
'UPDATE %T SET rules = %s WHERE id = %d',
|
|
$table->getTableName(),
|
|
json_encode($new_rules),
|
|
$policy->getID());
|
|
}
|