mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-26 23:40:57 +01:00
Migrate all "accountID" values to "ExternalAccountIdentifier" objects
Summary: Depends on D21016. Ref T13493. This copies existing external account "accountID" values into the "ExternalAccountIdentifier" table, preparing for an authority switch. Test Plan: Ran migration several times, looked at the data that came out of it, saw sensible results. Logged out / in with external accounts. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13493 Differential Revision: https://secure.phabricator.com/D21017
This commit is contained in:
parent
bcaf60015a
commit
faf9f06e0a
1 changed files with 40 additions and 0 deletions
40
resources/sql/autopatches/20200222.xident.01.migrate.php
Normal file
40
resources/sql/autopatches/20200222.xident.01.migrate.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
$account_table = new PhabricatorExternalAccount();
|
||||
$identifier_table = new PhabricatorExternalAccountIdentifier();
|
||||
|
||||
$conn = $account_table->establishConnection('w');
|
||||
$table_name = $account_table->getTableName();
|
||||
|
||||
$iterator = new LiskRawMigrationIterator($conn, $table_name);
|
||||
foreach ($iterator as $account_row) {
|
||||
// We don't need to migrate "accountID" values for "password" accounts,
|
||||
// since these were dummy values in the first place and are no longer
|
||||
// read or written after D21014. (There would be no harm in writing these
|
||||
// rows, but it's easy to skip them.)
|
||||
|
||||
if ($account_row['accountType'] === 'password') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$account_id = $account_row['accountID'];
|
||||
if (!strlen($account_id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
queryfx(
|
||||
$conn,
|
||||
'INSERT IGNORE INTO %R (
|
||||
phid, externalAccountPHID, providerConfigPHID,
|
||||
identifierHash, identifierRaw,
|
||||
dateCreated, dateModified)
|
||||
VALUES (%s, %s, %s, %s, %s, %d, %d)',
|
||||
$identifier_table,
|
||||
$identifier_table->generatePHID(),
|
||||
$account_row['phid'],
|
||||
$account_row['providerConfigPHID'],
|
||||
PhabricatorHash::digestForIndex($account_id),
|
||||
$account_id,
|
||||
$account_row['dateCreated'],
|
||||
$account_row['dateModified']);
|
||||
}
|
Loading…
Reference in a new issue