@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make two ancient migrations fatal if they affect data

Summary:
Depends on D20106. Ref T6703. Since I plan to change the `ExternalAccount` table, these migrations (which rely on `save()`) will stop working.

They could be rewritten to use raw queries, but I suspect few or no installs are affected. At least for now, just make them safe: if they would affect data, fatal and tell the user to perform a more gradual upgrade.

Also remove an `ALTER IGNORE TABLE` (this syntax was removed at some point) and fix a `%Q` when adjusting certain types of primary keys.

Test Plan: Ran `bin/storage upgrade --no-quickstart --force --namespace test1234` to get a complete migration since the beginning of time.

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T6703

Differential Revision: https://secure.phabricator.com/D20107

+19 -98
+2 -2
resources/sql/patches/133.imagemacro.sql
··· 1 - ALTER IGNORE TABLE `{$NAMESPACE}_file`.`file_imagemacro` 2 - ADD UNIQUE `name` (`name`); 1 + ALTER TABLE `{$NAMESPACE}_file`.`file_imagemacro` 2 + ADD UNIQUE KEY `name` (`name`);
+8 -60
resources/sql/patches/20130611.migrateoauth.php
··· 1 1 <?php 2 2 3 - // NOTE: We aren't using PhabricatorUserOAuthInfo anywhere here because it is 4 - // getting nuked in a future diff. 5 - 6 3 $table = new PhabricatorUser(); 4 + $conn = $table->establishConnection('w'); 7 5 $table_name = 'user_oauthinfo'; 8 - $conn_w = $table->establishConnection('w'); 9 - 10 - $xaccount = new PhabricatorExternalAccount(); 11 - 12 - echo pht('Migrating OAuth to %s...', 'ExternalAccount')."\n"; 13 6 14 - $domain_map = array( 15 - 'disqus' => 'disqus.com', 16 - 'facebook' => 'facebook.com', 17 - 'github' => 'github.com', 18 - 'google' => 'google.com', 19 - ); 20 - 21 - try { 22 - $phabricator_oauth_uri = new PhutilURI( 23 - PhabricatorEnv::getEnvConfig('phabricator.oauth-uri')); 24 - $domain_map['phabricator'] = $phabricator_oauth_uri->getDomain(); 25 - } catch (Exception $ex) { 26 - // Ignore; this likely indicates that we have removed `phabricator.oauth-uri` 27 - // in some future diff. 28 - } 29 - 30 - $rows = queryfx_all( 31 - $conn_w, 32 - 'SELECT * FROM user_oauthinfo'); 33 - foreach ($rows as $row) { 34 - echo pht('Migrating row ID #%d.', $row['id'])."\n"; 35 - $user = id(new PhabricatorUser())->loadOneWhere( 36 - 'id = %d', 37 - $row['userID']); 38 - if (!$user) { 39 - echo pht('Bad user ID!')."\n"; 40 - continue; 41 - } 42 - 43 - $domain = idx($domain_map, $row['oauthProvider']); 44 - if (empty($domain)) { 45 - echo pht('Unknown OAuth provider!')."\n"; 46 - continue; 47 - } 48 - 49 - 50 - $xaccount = id(new PhabricatorExternalAccount()) 51 - ->setUserPHID($user->getPHID()) 52 - ->setAccountType($row['oauthProvider']) 53 - ->setAccountDomain($domain) 54 - ->setAccountID($row['oauthUID']) 55 - ->setAccountURI($row['accountURI']) 56 - ->setUsername($row['accountName']) 57 - ->setDateCreated($row['dateCreated']); 58 - 59 - try { 60 - $xaccount->save(); 61 - } catch (Exception $ex) { 62 - phlog($ex); 63 - } 7 + foreach (new LiskRawMigrationIterator($conn, $table_name) as $row) { 8 + throw new Exception( 9 + pht( 10 + 'Your Phabricator install has ancient OAuth account data and is '. 11 + 'too old to upgrade directly to a modern version of Phabricator. '. 12 + 'Upgrade to a version released between June 2013 and February 2019 '. 13 + 'first, then upgrade to a modern version.')); 64 14 } 65 - 66 - echo pht('Done.')."\n";
+8 -35
resources/sql/patches/20130611.nukeldap.php
··· 1 1 <?php 2 2 3 - // NOTE: We aren't using PhabricatorUserLDAPInfo anywhere here because it is 4 - // being nuked by this change 5 - 6 3 $table = new PhabricatorUser(); 4 + $conn = $table->establishConnection('w'); 7 5 $table_name = 'user_ldapinfo'; 8 - $conn_w = $table->establishConnection('w'); 9 6 10 - $xaccount = new PhabricatorExternalAccount(); 11 - 12 - echo pht('Migrating LDAP to %s...', 'ExternalAccount')."\n"; 13 - 14 - $rows = queryfx_all($conn_w, 'SELECT * FROM %T', $table_name); 15 - foreach ($rows as $row) { 16 - echo pht('Migrating row ID #%d.', $row['id'])."\n"; 17 - $user = id(new PhabricatorUser())->loadOneWhere( 18 - 'id = %d', 19 - $row['userID']); 20 - if (!$user) { 21 - echo pht('Bad user ID!')."\n"; 22 - continue; 23 - } 24 - 25 - 26 - $xaccount = id(new PhabricatorExternalAccount()) 27 - ->setUserPHID($user->getPHID()) 28 - ->setAccountType('ldap') 29 - ->setAccountDomain('self') 30 - ->setAccountID($row['ldapUsername']) 31 - ->setUsername($row['ldapUsername']) 32 - ->setDateCreated($row['dateCreated']); 33 - 34 - try { 35 - $xaccount->save(); 36 - } catch (Exception $ex) { 37 - phlog($ex); 38 - } 7 + foreach (new LiskRawMigrationIterator($conn, $table_name) as $row) { 8 + throw new Exception( 9 + pht( 10 + 'Your Phabricator install has ancient LDAP account data and is '. 11 + 'too old to upgrade directly to a modern version of Phabricator. '. 12 + 'Upgrade to a version released between June 2013 and February 2019 '. 13 + 'first, then upgrade to a modern version.')); 39 14 } 40 - 41 - echo pht('Done.')."\n";
+1 -1
src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php
··· 432 432 case 'key': 433 433 if (($phase == 'drop_keys') && $adjust['exists']) { 434 434 if ($adjust['name'] == 'PRIMARY') { 435 - $key_name = 'PRIMARY KEY'; 435 + $key_name = qsprintf($conn, 'PRIMARY KEY'); 436 436 } else { 437 437 $key_name = qsprintf($conn, 'KEY %T', $adjust['name']); 438 438 }