Page MenuHomePhabricator

D18756.diff
No OneTemporary

D18756.diff

diff --git a/resources/sql/autopatches/20171101.diff.01.active.sql b/resources/sql/autopatches/20171101.diff.01.active.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20171101.diff.01.active.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_differential.differential_revision
+ ADD activeDiffPHID VARBINARY(64) NOT NULL;
diff --git a/resources/sql/autopatches/20171101.diff.02.populate.php b/resources/sql/autopatches/20171101.diff.02.populate.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20171101.diff.02.populate.php
@@ -0,0 +1,24 @@
+<?php
+
+$table = new DifferentialRevision();
+$conn = $table->establishConnection('w');
+$diff_table = new DifferentialDiff();
+
+foreach (new LiskMigrationIterator($table) as $revision) {
+ $revision_id = $revision->getID();
+
+ $diff_row = queryfx_one(
+ $conn,
+ 'SELECT phid FROM %T WHERE revisionID = %d ORDER BY id DESC LIMIT 1',
+ $diff_table->getTableName(),
+ $revision_id);
+
+ if ($diff_row) {
+ queryfx(
+ $conn,
+ 'UPDATE %T SET activeDiffPHID = %s WHERE id = %d',
+ $table->getTableName(),
+ $diff_row['phid'],
+ $revision_id);
+ }
+}
diff --git a/src/applications/differential/editor/DifferentialTransactionEditor.php b/src/applications/differential/editor/DifferentialTransactionEditor.php
--- a/src/applications/differential/editor/DifferentialTransactionEditor.php
+++ b/src/applications/differential/editor/DifferentialTransactionEditor.php
@@ -138,8 +138,7 @@
$object->setRepositoryPHID($diff->getRepositoryPHID());
}
$object->attachActiveDiff($diff);
-
- // TODO: Update the `diffPHID` once we add that.
+ $object->setActiveDiffPHID($diff->getPHID());
return;
}
diff --git a/src/applications/differential/storage/DifferentialRevision.php b/src/applications/differential/storage/DifferentialRevision.php
--- a/src/applications/differential/storage/DifferentialRevision.php
+++ b/src/applications/differential/storage/DifferentialRevision.php
@@ -35,6 +35,8 @@
protected $mailKey;
protected $branchName;
protected $repositoryPHID;
+ protected $activeDiffPHID;
+
protected $viewPolicy = PhabricatorPolicies::POLICY_USER;
protected $editPolicy = PhabricatorPolicies::POLICY_USER;
protected $properties = array();

File Metadata

Mime Type
text/plain
Expires
Mon, May 13, 11:13 PM (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6293725
Default Alt Text
D18756.diff (2 KB)

Event Timeline