mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
Change migrations to not rely on "arcanist project" classes
Summary: Ref T7604. Change two migrations to query arcanist project information using `queryfx` directly to avoid the need for the `LiskDAO` fields to exist. Test Plan: Ran the following commands to verify that things weren't majorly broken: - `./bin/storage upgrade --apply phabricator:20150503.repositorysymbols.2.php` - `./bin/storage upgrade --no-quickstart --namespace test` Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7604 Differential Revision: https://secure.phabricator.com/D13011
This commit is contained in:
parent
bb92819c09
commit
7bea116b00
2 changed files with 12 additions and 41 deletions
|
@ -1,26 +1,29 @@
|
|||
<?php
|
||||
|
||||
$projects = id(new PhabricatorRepositoryArcanistProjectQuery())
|
||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
||||
->needRepositories(true)
|
||||
->execute();
|
||||
|
||||
$table = new PhabricatorRepositorySymbol();
|
||||
$conn_w = $table->establishConnection('w');
|
||||
|
||||
$projects = queryfx_all(
|
||||
$conn_w,
|
||||
'SELECT * FROM %T',
|
||||
'repository_arcanistproject');
|
||||
|
||||
foreach ($projects as $project) {
|
||||
$repo = $project->getRepository();
|
||||
$repo = id(new PhabricatorRepositoryQuery())
|
||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
||||
->withIDs(array($project['repository']))
|
||||
->executeOne();
|
||||
|
||||
if (!$repo) {
|
||||
continue;
|
||||
}
|
||||
|
||||
echo pht("Migrating symbols for '%s' project...\n", $project->getName());
|
||||
echo pht("Migrating symbols for '%s' project...\n", $project['name']);
|
||||
|
||||
queryfx(
|
||||
$conn_w,
|
||||
'UPDATE %T SET repositoryPHID = %s WHERE arcanistProjectID = %d',
|
||||
$table->getTableName(),
|
||||
$repo->getPHID(),
|
||||
$project->getID());
|
||||
$project['id']);
|
||||
}
|
||||
|
|
|
@ -1,35 +1,3 @@
|
|||
<?php
|
||||
|
||||
$table = new DifferentialRevision();
|
||||
$table->openTransaction();
|
||||
$table->beginReadLocking();
|
||||
$conn_w = $table->establishConnection('w');
|
||||
|
||||
echo pht('Migrating revisions')."\n";
|
||||
do {
|
||||
$revisions = $table->loadAllWhere('branchName IS NULL LIMIT 1000');
|
||||
|
||||
foreach ($revisions as $revision) {
|
||||
echo '.';
|
||||
|
||||
$diff = $revision->loadActiveDiff();
|
||||
if (!$diff) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$branch_name = $diff->getBranch();
|
||||
$arc_project_phid = $diff->getArcanistProjectPHID();
|
||||
|
||||
queryfx(
|
||||
$conn_w,
|
||||
'UPDATE %T SET branchName = %s, arcanistProjectPHID = %s WHERE id = %d',
|
||||
$table->getTableName(),
|
||||
$branch_name,
|
||||
$arc_project_phid,
|
||||
$revision->getID());
|
||||
}
|
||||
} while (count($revisions) == 1000);
|
||||
|
||||
$table->endReadLocking();
|
||||
$table->saveTransaction();
|
||||
echo "\n".pht('Done.')."\n";
|
||||
// This migration has been dropped, see T7604 for details.
|
||||
|
|
Loading…
Reference in a new issue