1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-05 13:16:14 +01:00
phorge-phorge/resources/sql/autopatches/20190206.external.04.providerlink.php

37 lines
839 B
PHP
Raw Normal View History

<?php
$account_table = new PhabricatorExternalAccount();
$account_conn = $account_table->establishConnection('w');
$table_name = $account_table->getTableName();
$config_table = new PhabricatorAuthProviderConfig();
$config_conn = $config_table->establishConnection('w');
foreach (new LiskRawMigrationIterator($account_conn, $table_name) as $row) {
if (strlen($row['providerConfigPHID'])) {
continue;
}
$config_row = queryfx_one(
$config_conn,
'SELECT phid
FROM %R
WHERE providerType = %s AND providerDomain = %s
LIMIT 1',
$config_table,
$row['accountType'],
$row['accountDomain']);
if (!$config_row) {
continue;
}
queryfx(
$account_conn,
'UPDATE %R
SET providerConfigPHID = %s
WHERE id = %d',
$account_table,
$config_row['phid'],
$row['id']);
}