Page MenuHomePhabricator

Build a phabricator cli tool to migrate projects into subprojects / milestones.
Closed, DeclinedPublic

Description

Upstream: https://secure.phabricator.com/T10350

At the new Phabricator version (currently deployed at phab-01.wmflabs.org) you can add subprojects. But there is one big disadvantage: You can not reorganize the current setting, for example, you have the normal projects a and b. You can not make b to a subproject of a. You have to create a new b as a subproject of a, and archive the old b.

But there is one alternative: You can change the DB to mark projects as subprojects: It's easy:

Preparation

The process

  • Get the existing data of the (future) subproject, you need this columns:

mysql> SELECT name, projectPath, projectDepth, parentProjectPHID from project where name = '<Name of the project>';
At my example I get the following content:

+-------------------+-------------+--------------+-------------------+
| name              | projectPath | projectDepth | parentProjectPHID |
+-------------------+-------------+--------------+-------------------+
| Project_B         | KXZN        |            0 | NULL              |
+-------------------+-------------+--------------+-------------------+
1 row in set (0.00 sec)
WARNING: projectDepth must have the value 0, otherwise this object is already a subproject (same at parentProjectPHID , this value have to be NULL)
  • Adjust the needed values:
    • Increase projectDepth: 0 => 1 (If you want to add this as a subproject of a subprohject you have to choose 2, etc)
    • Set parentProjectPHID to the PHID of "parentproject"
    • ProjectPath: This part is a bit different. At first you need the projectPath from the "parentproject":

For example:

+---------------+-------------+
| name          | projectPath |
+---------------+-------------+
| Project_A     | fwND        |
+---------------+-------------+
1 row in set (0.00 sec)

So the path of the project is "fwND" in this example. For the subproject, you have to take the path of the project, and add the existing path of the subproject to it. (Project A - fwND; Project B - KXZN) Result: "fwNDKXZN"
Now you have to change these three values, after that the entry should look like this:

+-----------------+-------------+--------------+--------------------------------+
| name            | projectPath | projectDepth | parentProjectPHID              |
+-----------------+-------------+--------------+--------------------------------+
| Project_B       | fwNDDWus    |            1 | PHID-PROJ-i3ka2ejyihk6yqey4te2 |
+-----------------+-------------+--------------+--------------------------------+
1 row in set (0.00 sec)

If it is correct, you have a subproject now.

Special Case B

If the parentproject did not have any subprojects yet, you have to change an additional value, for example:

+---------------+----------------+
| name          | hasSubprojects |
+---------------+----------------+
| Project_A     |              0 |
+---------------+----------------+
1 row in set (0.00 sec)

In this case you have to set the boolean "hasSubprojects" to 1, because you want that this project has subprojects now ;).

Event Timeline

Luke081515 raised the priority of this task from to Needs Triage.
Luke081515 updated the task description. (Show Details)
Luke081515 added a project: Phabricator.
Luke081515 added subscribers: Luke081515, mmodell.
mmodell triaged this task as Medium priority.Jan 8 2016, 4:07 AM

This is a nice write up, thanks Luke081515. But this seems more like documentation than an actual task. Is the closing criteria for this going to be that existing pretend-subprojects will be made proper after the upgrade?

Should I write a documentation for marking projects as milestones too, or is this not needed? (The way is a little bit different)

Should I write a documentation for marking projects as milestones too, or is this not needed? (The way is a little bit different)

Sure if you have time. But I second @Krenair's comment of putting this on-wiki somewhere.

Thanks a ton for this.

(Maybe we can use this as tracking task for marking projects as subprojects)

Note that I asked for this upstream and @epriestley pointed me back to here, so I created https://secure.phabricator.com/T10350 as a wishlist item. :-)

let's re-purpose this task to "make a tool that does this" - I think I could write that tool fairly easily.

I mean, easily thanks to @Luke081515 doing all the hard work. :) thanks for that

mmodell renamed this task from Mark existing projects as subprojects to Build a phabricator cli tool to migrate projects into subprojects / milestones..Feb 12 2016, 10:36 PM
mmodell updated the task description. (Show Details)

The process above is substantially correct, but doesn't deal with merging members, which is complicated. I started a script for this in the upstream, here:

https://secure.phabricator.com/T10350

That might not do everything you want/need, but may be helpful as a starting point.

Closing because the upstream scripts look like they will do everything we need.

Thanks @epriestley!

I don't see recent updates at https://secure.phabricator.com/T10350 . If the script works, please mark this as resolved.