Cut mirroring over to new URIs
Summary: Ref T10748. This migrates and swaps mirroring to `PhabricatorRepositoryURI`, obsoleting `PhabricatorRepositoryMirror`. This prevents you from editing, adding or disabling mirrors unless you know a secret URI (until the UI cuts over fully), but existing mirroring is not affected. Test Plan: - Added a mirroring URI to an old repository. - Verified it worked with `bin/repository mirror`. - Migrated forward. - Verified it still worked with `bin/repository mirror`. - Wow, mirroring: https://github.com/epriestley/locktopia-mirror Reviewers: chad Reviewed By: chad Maniphest Tasks: T10748 Differential Revision: https://secure.phabricator.com/D15841
This commit is contained in:
38
resources/sql/autopatches/20160503.repo.04.mirrormigrate.php
Normal file
38
resources/sql/autopatches/20160503.repo.04.mirrormigrate.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
$table = new PhabricatorRepository();
|
||||
$conn_w = $table->establishConnection('w');
|
||||
|
||||
$mirrors = queryfx_all(
|
||||
$conn_w,
|
||||
'SELECT * FROM %T',
|
||||
'repository_mirror');
|
||||
|
||||
foreach ($mirrors as $mirror) {
|
||||
$repository_phid = $mirror['repositoryPHID'];
|
||||
$uri = $mirror['remoteURI'];
|
||||
|
||||
$already_exists = id(new PhabricatorRepositoryURI())->loadOneWhere(
|
||||
'repositoryPHID = %s AND uri = %s',
|
||||
$repository_phid,
|
||||
$uri);
|
||||
if ($already_exists) {
|
||||
// Decline to migrate stuff that looks like it was already migrated.
|
||||
continue;
|
||||
}
|
||||
|
||||
$new_uri = PhabricatorRepositoryURI::initializeNewURI()
|
||||
->setIOType(PhabricatorRepositoryURI::IO_MIRROR)
|
||||
->setRepositoryPHID($repository_phid)
|
||||
->setURI($uri)
|
||||
->setCredentialPHID($mirror['credentialPHID'])
|
||||
->setDateCreated($mirror['dateCreated'])
|
||||
->setDateModified($mirror['dateModified'])
|
||||
->save();
|
||||
|
||||
echo tsprintf(
|
||||
"%s\n",
|
||||
pht(
|
||||
'Migrated mirror "%s".',
|
||||
$uri));
|
||||
}
|
||||
Reference in New Issue
Block a user