Migrate PhabricatorUserLDAPInfo to PhabricatorExternalAccount
Summary: Ref T1536. This is similar to D6172 but much simpler: we don't need to retain external interfaces here and can do a straight migration. Test Plan: TBA Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1536 Differential Revision: https://secure.phabricator.com/D6173
This commit is contained in:
41
resources/sql/patches/20130611.nukeldap.php
Normal file
41
resources/sql/patches/20130611.nukeldap.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
// NOTE: We aren't using PhabricatorUserLDAPInfo anywhere here because it is
|
||||
// being nuked by this change
|
||||
|
||||
$table = new PhabricatorUser();
|
||||
$table_name = 'user_ldapinfo';
|
||||
$conn_w = $table->establishConnection('w');
|
||||
|
||||
$xaccount = new PhabricatorExternalAccount();
|
||||
|
||||
echo "Migrating LDAP to ExternalAccount...\n";
|
||||
|
||||
$rows = queryfx_all($conn_w, 'SELECT * FROM %T', $table_name);
|
||||
foreach ($rows as $row) {
|
||||
echo "Migrating row ID #".$row['id'].".\n";
|
||||
$user = id(new PhabricatorUser())->loadOneWhere(
|
||||
'id = %d',
|
||||
$row['userID']);
|
||||
if (!$user) {
|
||||
echo "Bad user ID!\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$xaccount = id(new PhabricatorExternalAccount())
|
||||
->setUserPHID($user->getPHID())
|
||||
->setAccountType('ldap')
|
||||
->setAccountDomain('self')
|
||||
->setAccountID($row['ldapUsername'])
|
||||
->setUsername($row['ldapUsername'])
|
||||
->setDateCreated($row['dateCreated']);
|
||||
|
||||
try {
|
||||
$xaccount->save();
|
||||
} catch (Exception $ex) {
|
||||
phlog($ex);
|
||||
}
|
||||
}
|
||||
|
||||
echo "Done.\n";
|
||||
Reference in New Issue
Block a user