Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/autopatches/20140722.appname.php
| Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | foreach ($applications as $application) { | ||||
| $old_name = 'PhabricatorApplication'.$application; | $old_name = 'PhabricatorApplication'.$application; | ||||
| $new_name = 'Phabricator'.$application.'Application'; | $new_name = 'Phabricator'.$application.'Application'; | ||||
| $map[$old_name] = $new_name; | $map[$old_name] = $new_name; | ||||
| } | } | ||||
| /* -( User preferences )--------------------------------------------------- */ | /* -( User preferences )--------------------------------------------------- */ | ||||
| echo "Migrating user preferences...\n"; | echo pht('Migrating user preferences...')."\n"; | ||||
| $table = new PhabricatorUserPreferences(); | $table = new PhabricatorUserPreferences(); | ||||
| $conn_w = $table->establishConnection('w'); | $conn_w = $table->establishConnection('w'); | ||||
| $pref_pinned = PhabricatorUserPreferences::PREFERENCE_APP_PINNED; | $pref_pinned = PhabricatorUserPreferences::PREFERENCE_APP_PINNED; | ||||
| foreach (new LiskMigrationIterator(new PhabricatorUser()) as $user) { | foreach (new LiskMigrationIterator(new PhabricatorUser()) as $user) { | ||||
| $user_preferences = $user->loadPreferences(); | $user_preferences = $user->loadPreferences(); | ||||
| $old_pinned_apps = $user_preferences->getPreference($pref_pinned); | $old_pinned_apps = $user_preferences->getPreference($pref_pinned); | ||||
| Show All 16 Lines | queryfx( | ||||
| $user_preferences->getTableName(), | $user_preferences->getTableName(), | ||||
| json_encode($user_preferences->getPreferences()), | json_encode($user_preferences->getPreferences()), | ||||
| $user_preferences->getID()); | $user_preferences->getID()); | ||||
| } | } | ||||
| /* -( Dashboard installs )------------------------------------------------- */ | /* -( Dashboard installs )------------------------------------------------- */ | ||||
| echo "Migrating dashboard installs...\n"; | echo pht('Migrating dashboard installs...')."\n"; | ||||
| $table = new PhabricatorDashboardInstall(); | $table = new PhabricatorDashboardInstall(); | ||||
| $conn_w = $table->establishConnection('w'); | $conn_w = $table->establishConnection('w'); | ||||
| foreach (new LiskMigrationIterator($table) as $dashboard_install) { | foreach (new LiskMigrationIterator($table) as $dashboard_install) { | ||||
| $application = $dashboard_install->getApplicationClass(); | $application = $dashboard_install->getApplicationClass(); | ||||
| queryfx( | queryfx( | ||||
| $conn_w, | $conn_w, | ||||
| 'UPDATE %T SET applicationClass = %s WHERE id = %d', | 'UPDATE %T SET applicationClass = %s WHERE id = %d', | ||||
| $table->getTableName(), | $table->getTableName(), | ||||
| idx($map, $application, $application), | idx($map, $application, $application), | ||||
| $dashboard_install->getID()); | $dashboard_install->getID()); | ||||
| } | } | ||||
| /* -( Phabricator configuration )------------------------------------------ */ | /* -( Phabricator configuration )------------------------------------------ */ | ||||
| $config_key = 'phabricator.uninstalled-applications'; | $config_key = 'phabricator.uninstalled-applications'; | ||||
| echo "Migrating `{$config_key}` config...\n"; | echo pht('Migrating `%s` config...', $config_key)."\n"; | ||||
| $config = PhabricatorConfigEntry::loadConfigEntry($config_key); | $config = PhabricatorConfigEntry::loadConfigEntry($config_key); | ||||
| $old_config = $config->getValue(); | $old_config = $config->getValue(); | ||||
| $new_config = array(); | $new_config = array(); | ||||
| if ($old_config) { | if ($old_config) { | ||||
| foreach ($old_config as $application => $uninstalled) { | foreach ($old_config as $application => $uninstalled) { | ||||
| $new_config[idx($map, $application, $application)] = $uninstalled; | $new_config[idx($map, $application, $application)] = $uninstalled; | ||||
| } | } | ||||
| $config | $config | ||||
| ->setIsDeleted(0) | ->setIsDeleted(0) | ||||
| ->setValue($new_config) | ->setValue($new_config) | ||||
| ->save(); | ->save(); | ||||
| } | } | ||||
| /* -( phabricator.application-settings )----------------------------------- */ | /* -( phabricator.application-settings )----------------------------------- */ | ||||
| $config_key = 'phabricator.application-settings'; | $config_key = 'phabricator.application-settings'; | ||||
| echo "Migrating `{$config_key}` config...\n"; | echo pht('Migrating `%s` config...', $config_key)."\n"; | ||||
| $config = PhabricatorConfigEntry::loadConfigEntry($config_key); | $config = PhabricatorConfigEntry::loadConfigEntry($config_key); | ||||
| $old_config = $config->getValue(); | $old_config = $config->getValue(); | ||||
| $new_config = array(); | $new_config = array(); | ||||
| if ($old_config) { | if ($old_config) { | ||||
| foreach ($old_config as $application => $settings) { | foreach ($old_config as $application => $settings) { | ||||
| $application = preg_replace('/^PHID-APPS-/', '', $application); | $application = preg_replace('/^PHID-APPS-/', '', $application); | ||||
| $new_config['PHID-APPS-'.idx($map, $application, $application)] = $settings; | $new_config['PHID-APPS-'.idx($map, $application, $application)] = $settings; | ||||
| } | } | ||||
| $config | $config | ||||
| ->setIsDeleted(0) | ->setIsDeleted(0) | ||||
| ->setValue($new_config) | ->setValue($new_config) | ||||
| ->save(); | ->save(); | ||||
| } | } | ||||