1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00
phorge-phorge/resources/sql/autopatches/20180306.opath.02.digestpopulate.php
epriestley 1bf4422c74 Add and populate a pathIndex column for OwnersPath
Summary: Ref T11015. This supports making path names arbitrarily long and putting a proper unique key on the table.

Test Plan:
  - Migrated, checked database, saw nice digested indexes.
  - Edited a package, saw new rows update with digested indexes.

Maniphest Tasks: T11015

Differential Revision: https://secure.phabricator.com/D19181
2018-03-06 20:30:33 -08:00

19 lines
402 B
PHP

<?php
$table = new PhabricatorOwnersPath();
$conn = $table->establishConnection('w');
foreach (new LiskMigrationIterator($table) as $path) {
$index = PhabricatorHash::digestForIndex($path->getPath());
if ($index === $path->getPathIndex()) {
continue;
}
queryfx(
$conn,
'UPDATE %T SET pathIndex = %s WHERE id = %d',
$table->getTableName(),
$index,
$path->getID());
}