Skip to content

Commit 01ea840

Browse files
author
epriestley
committedMar 15, 2021
Update table schema for "AffectedPath" table
Summary: Ref T13639. Make schema changes: - Make repositoryID nullable, for revisions with no repository. - Remove "epoch", which has no readers and no clear use. - Change the ordering of the key, since "pathID" has more unique values and no queries ever issue without it. Test Plan: - Ran `bin/storage upgrade`, got a clean schema. - Reindexed all revisions with an external script. - Reviewed index via debug UI, saw appropriate index for non-repositoy revisions. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13639 Differential Revision: https://secure.phabricator.com/D21617
1 parent 38ef910 commit 01ea840

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE {$NAMESPACE}_differential.differential_affectedpath
2+
DROP epoch;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE {$NAMESPACE}_differential.differential_affectedpath
2+
CHANGE repositoryID repositoryID INT UNSIGNED;

‎src/applications/differential/engine/DifferentialAffectedPathEngine.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function updateAffectedPaths() {
3232
if ($repository) {
3333
$repository_id = $repository->getID();
3434
} else {
35-
return;
35+
$repository_id = null;
3636
}
3737

3838
$paths = $this->getAffectedPaths();
@@ -48,10 +48,9 @@ public function updateAffectedPaths() {
4848
foreach ($path_ids as $path_id) {
4949
$sql[] = qsprintf(
5050
$conn,
51-
'(%d, %d, %d, %d)',
51+
'(%nd, %d, %d)',
5252
$repository_id,
5353
$path_id,
54-
PhabricatorTime::getNow(),
5554
$revision->getID());
5655
}
5756

@@ -64,7 +63,7 @@ public function updateAffectedPaths() {
6463
foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) {
6564
queryfx(
6665
$conn,
67-
'INSERT INTO %R (repositoryID, pathID, epoch, revisionID) VALUES %LQ',
66+
'INSERT INTO %R (repositoryID, pathID, revisionID) VALUES %LQ',
6867
$table,
6968
$chunk);
7069
}

‎src/applications/differential/storage/DifferentialAffectedPath.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ final class DifferentialAffectedPath extends DifferentialDAO {
88

99
protected $repositoryID;
1010
protected $pathID;
11-
protected $epoch;
1211
protected $revisionID;
1312

1413
protected function getConfiguration() {
1514
return array(
1615
self::CONFIG_TIMESTAMPS => false,
1716
self::CONFIG_COLUMN_SCHEMA => array(
1817
'id' => null,
18+
'repositoryID' => 'id?',
1919
),
2020
self::CONFIG_KEY_SCHEMA => array(
2121
'PRIMARY' => null,
22-
'repositoryID' => array(
23-
'columns' => array('repositoryID', 'pathID', 'epoch'),
24-
),
2522
'revisionID' => array(
2623
'columns' => array('revisionID'),
2724
),
25+
'key_path' => array(
26+
'columns' => array('pathID', 'repositoryID'),
27+
),
2828
),
2929
) + parent::getConfiguration();
3030
}

0 commit comments

Comments
 (0)
Failed to load comments.