@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

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

+30 -2
+2
resources/sql/autopatches/20180306.opath.01.digest.sql
··· 1 + ALTER TABLE {$NAMESPACE}_owners.owners_path 2 + ADD pathIndex BINARY(12) NOT NULL;
+19
resources/sql/autopatches/20180306.opath.02.digestpopulate.php
··· 1 + <?php 2 + 3 + $table = new PhabricatorOwnersPath(); 4 + $conn = $table->establishConnection('w'); 5 + 6 + foreach (new LiskMigrationIterator($table) as $path) { 7 + $index = PhabricatorHash::digestForIndex($path->getPath()); 8 + 9 + if ($index === $path->getPathIndex()) { 10 + continue; 11 + } 12 + 13 + queryfx( 14 + $conn, 15 + 'UPDATE %T SET pathIndex = %s WHERE id = %d', 16 + $table->getTableName(), 17 + $index, 18 + $path->getID()); 19 + }
+9 -2
src/applications/owners/storage/PhabricatorOwnersPath.php
··· 4 4 5 5 protected $packageID; 6 6 protected $repositoryPHID; 7 + protected $pathIndex; 7 8 protected $path; 8 9 protected $excluded; 9 10 ··· 15 16 self::CONFIG_TIMESTAMPS => false, 16 17 self::CONFIG_COLUMN_SCHEMA => array( 17 18 'path' => 'text255', 19 + 'pathIndex' => 'bytes12', 18 20 'excluded' => 'bool', 19 21 ), 20 22 self::CONFIG_KEY_SCHEMA => array( ··· 24 26 ), 25 27 ) + parent::getConfiguration(); 26 28 } 27 - 28 29 29 30 public static function newFromRef(array $ref) { 30 31 $path = new PhabricatorOwnersPath(); 31 32 $path->repositoryPHID = $ref['repositoryPHID']; 32 - $path->path = $ref['path']; 33 + 34 + $raw_path = $ref['path']; 35 + 36 + $path->pathIndex = PhabricatorHash::digestForIndex($raw_path); 37 + $path->path = $raw_path; 38 + 33 39 $path->excluded = $ref['excluded']; 40 + 34 41 return $path; 35 42 } 36 43