mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 11:30:55 +01:00
Add mailKeys to Ponder Answer
Summary: Ref T3846. Adds mailkey generation and migration. Test Plan: Ran the migration, see keys in mysql. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T3846 Differential Revision: https://secure.phabricator.com/D13785
This commit is contained in:
parent
328210a1a6
commit
4e7b5defc3
3 changed files with 29 additions and 0 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE {$NAMESPACE}_ponder.ponder_answer
|
||||||
|
ADD mailKey binary(20) NOT NULL;
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$table = new PonderAnswer();
|
||||||
|
$conn_w = $table->establishConnection('w');
|
||||||
|
$iterator = new LiskMigrationIterator($table);
|
||||||
|
foreach ($iterator as $answer) {
|
||||||
|
$id = $answer->getID();
|
||||||
|
|
||||||
|
echo pht('Adding mail key for Answer %d...', $id);
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
queryfx(
|
||||||
|
$conn_w,
|
||||||
|
'UPDATE %T SET mailKey = %s WHERE id = %d',
|
||||||
|
$table->getTableName(),
|
||||||
|
Filesystem::readRandomCharacters(20),
|
||||||
|
$id);
|
||||||
|
}
|
|
@ -18,6 +18,7 @@ final class PonderAnswer extends PonderDAO
|
||||||
|
|
||||||
protected $content;
|
protected $content;
|
||||||
protected $contentSource;
|
protected $contentSource;
|
||||||
|
protected $mailKey;
|
||||||
|
|
||||||
protected $voteCount;
|
protected $voteCount;
|
||||||
private $vote;
|
private $vote;
|
||||||
|
@ -71,6 +72,7 @@ final class PonderAnswer extends PonderDAO
|
||||||
self::CONFIG_COLUMN_SCHEMA => array(
|
self::CONFIG_COLUMN_SCHEMA => array(
|
||||||
'voteCount' => 'sint32',
|
'voteCount' => 'sint32',
|
||||||
'content' => 'text',
|
'content' => 'text',
|
||||||
|
'mailKey' => 'bytes20',
|
||||||
|
|
||||||
// T6203/NULLABILITY
|
// T6203/NULLABILITY
|
||||||
// This should always exist.
|
// This should always exist.
|
||||||
|
@ -113,6 +115,13 @@ final class PonderAnswer extends PonderDAO
|
||||||
return self::MARKUP_FIELD_CONTENT;
|
return self::MARKUP_FIELD_CONTENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function save() {
|
||||||
|
if (!$this->getMailKey()) {
|
||||||
|
$this->setMailKey(Filesystem::readRandomCharacters(20));
|
||||||
|
}
|
||||||
|
return parent::save();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
|
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue