1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-17 12:22:42 +01:00

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
This commit is contained in:
epriestley 2018-03-06 19:33:49 -08:00
parent d14a0f4787
commit 1bf4422c74
3 changed files with 30 additions and 2 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_owners.owners_path
ADD pathIndex BINARY(12) NOT NULL;

View file

@ -0,0 +1,19 @@
<?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());
}

View file

@ -4,6 +4,7 @@ final class PhabricatorOwnersPath extends PhabricatorOwnersDAO {
protected $packageID;
protected $repositoryPHID;
protected $pathIndex;
protected $path;
protected $excluded;
@ -15,6 +16,7 @@ final class PhabricatorOwnersPath extends PhabricatorOwnersDAO {
self::CONFIG_TIMESTAMPS => false,
self::CONFIG_COLUMN_SCHEMA => array(
'path' => 'text255',
'pathIndex' => 'bytes12',
'excluded' => 'bool',
),
self::CONFIG_KEY_SCHEMA => array(
@ -25,12 +27,17 @@ final class PhabricatorOwnersPath extends PhabricatorOwnersDAO {
) + parent::getConfiguration();
}
public static function newFromRef(array $ref) {
$path = new PhabricatorOwnersPath();
$path->repositoryPHID = $ref['repositoryPHID'];
$path->path = $ref['path'];
$raw_path = $ref['path'];
$path->pathIndex = PhabricatorHash::digestForIndex($raw_path);
$path->path = $raw_path;
$path->excluded = $ref['excluded'];
return $path;
}