1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00
phorge-phorge/resources/sql/patches/20130716.archivememberlessprojects.php
Bob Trahan 001f76cbaa Projects - tighten up a few things
Summary:
Fixes T2675, T2676.

 - when the last person leaves a project it is archived.
 - a script to archive all memberless projects
 - better feed stories for the various policy edits you can do
 - phriction pages are also moved as you rename projects

Test Plan: edited some projects and noted reasonable feed stories. ran script against test data and it worked! left a last man standing project and it archived. renamed a project to "a" then "b" then "a" (etc) and it worked including phrictiondocument moves

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2676, T2675

Differential Revision: https://secure.phabricator.com/D6478
2013-07-17 16:43:37 -07:00

39 lines
986 B
PHP

<?php
echo "Archiving projects with no members...\n";
$table = new PhabricatorProject();
$table->openTransaction();
foreach (new LiskMigrationIterator($table) as $project) {
$members = PhabricatorEdgeQuery::loadDestinationPHIDs(
$project->getPHID(),
PhabricatorEdgeConfig::TYPE_PROJ_MEMBER);
if (count($members)) {
echo sprintf(
'Project "%s" has %d members; skipping.',
$project->getName(),
count($members)), "\n";
continue;
}
if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ARCHIVED) {
echo sprintf(
'Project "%s" already archived; skipping.',
$project->getName()), "\n";
continue;
}
echo sprintf('Archiving project "%s"...', $project->getName()), "\n";
queryfx(
$table->establishConnection('w'),
'UPDATE %T SET status = %s WHERE id = %d',
$table->getTableName(),
PhabricatorProjectStatus::STATUS_ARCHIVED,
$project->getID());
}
$table->saveTransaction();
echo "\nDone.\n";