1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-30 10:42:41 +01:00
phorge-phorge/resources/sql/autopatches/20140805.boardcol.2.php
epriestley 09868271bd Move board relationships to dedicated storage
Summary:
Fixes T5476. Using edges to store which objects are on which board columns ends up being pretty awkward. In particular, it makes T4807 very difficult to implement.

Introduce a dedicated `BoardColumnPosition` storage.

This doesn't affect ordering rules (T4807) yet: boards are still arranged by priority. We just read which tasks are on which columns out of a new table.

Test Plan:
  - Migrated data, then viewed some boards. Saw exactly the same data.
  - Dragged tasks from column to column.
  - Created a task directly into a column.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5476

Differential Revision: https://secure.phabricator.com/D10160
2014-08-06 15:09:09 -07:00

53 lines
1.2 KiB
PHP

<?php
// Was PhabricatorEdgeConfig::TYPE_COLUMN_HAS_OBJECT
$type_has_object = 44;
$column = new PhabricatorProjectColumn();
$conn_w = $column->establishConnection('w');
$rows = queryfx_all(
$conn_w,
'SELECT src, dst FROM %T WHERE type = %d',
PhabricatorEdgeConfig::TABLE_NAME_EDGE,
$type_has_object);
$cols = array();
foreach ($rows as $row) {
$cols[$row['src']][] = $row['dst'];
}
$sql = array();
foreach ($cols as $col_phid => $obj_phids) {
echo "Migrating column '{$col_phid}'...\n";
$column = id(new PhabricatorProjectColumn())->loadOneWhere(
'phid = %s',
$col_phid);
if (!$column) {
echo "Column '{$col_phid}' does not exist.\n";
continue;
}
$sequence = 0;
foreach ($obj_phids as $obj_phid) {
$sql[] = qsprintf(
$conn_w,
'(%s, %s, %s, %d)',
$column->getProjectPHID(),
$column->getPHID(),
$obj_phid,
$sequence++);
}
}
echo "Inserting rows...\n";
foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) {
queryfx(
$conn_w,
'INSERT INTO %T (boardPHID, columnPHID, objectPHID, sequence)
VALUES %Q',
id(new PhabricatorProjectColumnPosition())->getTableName(),
$chunk);
}
echo "Done.\n";