diff --git a/resources/sql/patches/20130507.releephrqmailkey.sql b/resources/sql/patches/20130507.releephrqmailkey.sql new file mode 100644 index 0000000000..154a2cb22a --- /dev/null +++ b/resources/sql/patches/20130507.releephrqmailkey.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_releeph.releeph_request + ADD COLUMN `mailKey` varchar(20) NOT NULL; diff --git a/resources/sql/patches/20130507.releephrqmailkeypop.php b/resources/sql/patches/20130507.releephrqmailkeypop.php new file mode 100644 index 0000000000..49c1bc6495 --- /dev/null +++ b/resources/sql/patches/20130507.releephrqmailkeypop.php @@ -0,0 +1,27 @@ +openTransaction(); + +// From ponder-mailkey-populate.php... +foreach (new LiskMigrationIterator($table) as $rq) { + $id = $rq->getID(); + + echo "RQ{$id}: "; + if (!$rq->getMailKey()) { + queryfx( + $rq->establishConnection('w'), + 'UPDATE %T SET mailKey = %s WHERE id = %d', + $rq->getTableName(), + Filesystem::readRandomCharacters(20), + $id); + echo("Generated Key\n"); + } else { + echo "-\n"; + } +} + +$table->saveTransaction(); +echo "Done.\n"; diff --git a/src/applications/releeph/storage/ReleephRequest.php b/src/applications/releeph/storage/ReleephRequest.php index 67ab8d79d2..28505ad25d 100644 --- a/src/applications/releeph/storage/ReleephRequest.php +++ b/src/applications/releeph/storage/ReleephRequest.php @@ -9,6 +9,7 @@ final class ReleephRequest extends ReleephDAO { protected $userIntents = array(); protected $inBranch; protected $pickStatus; + protected $mailKey; // Information about the thing being requested protected $requestCommitPHID; @@ -153,6 +154,13 @@ final class ReleephRequest extends ReleephDAO { ReleephPHIDConstants::PHID_TYPE_RERQ); } + public function save() { + if (!$this->getMailKey()) { + $this->setMailKey(Filesystem::readRandomCharacters(20)); + } + return parent::save(); + } + /* -( Helpful accessors )--------------------------------------------------- */ diff --git a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php index c17ffd3d26..a86f8845eb 100644 --- a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php +++ b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php @@ -1274,6 +1274,14 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList { 'type' => 'sql', 'name' => $this->getPatchPath('20130507.releephrqsimplifycols.sql'), ), + '20130507.releephrqmailkey.sql' => array( + 'type' => 'sql', + 'name' => $this->getPatchPath('20130507.releephrqmailkey.sql'), + ), + '20130507.releephrqmailkeypop.php' => array( + 'type' => 'php', + 'name' => $this->getPatchPath('20130507.releephrqmailkeypop.php'), + ), ); } }