diff --git a/resources/sql/autopatches/20220525.slowvote.01.mailkey.php b/resources/sql/autopatches/20220525.slowvote.01.mailkey.php new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20220525.slowvote.01.mailkey.php @@ -0,0 +1,28 @@ +establishConnection('w'); + +$properties_table = new PhabricatorMetaMTAMailProperties(); +$conn = $properties_table->establishConnection('w'); + +$iterator = new LiskRawMigrationIterator( + $poll_conn, + $poll_table->getTableName()); + +foreach ($iterator as $row) { + queryfx( + $conn, + 'INSERT IGNORE INTO %R + (objectPHID, mailProperties, dateCreated, dateModified) + VALUES + (%s, %s, %d, %d)', + $properties_table, + $row['phid'], + phutil_json_encode( + array( + 'mailKey' => $row['mailKey'], + )), + PhabricatorTime::getNow(), + PhabricatorTime::getNow()); +} diff --git a/resources/sql/autopatches/20220525.slowvote.02.mailkey-drop.sql b/resources/sql/autopatches/20220525.slowvote.02.mailkey-drop.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20220525.slowvote.02.mailkey-drop.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_slowvote.slowvote_poll + DROP mailKey; diff --git a/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php b/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php --- a/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php +++ b/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php @@ -1,6 +1,7 @@ 'uint32', 'description' => 'text', 'isClosed' => 'bool', - 'mailKey' => 'bytes20', ), self::CONFIG_KEY_SCHEMA => array( ), ) + parent::getConfiguration(); } - public function generatePHID() { - return PhabricatorPHID::generateNewPHID( - PhabricatorSlowvotePollPHIDType::TYPECONST); + public function getPHIDType() { + return PhabricatorSlowvotePollPHIDType::TYPECONST; } public function getOptions() { @@ -112,13 +110,6 @@ return '/'.$this->getMonogram(); } - public function save() { - if (!$this->getMailKey()) { - $this->setMailKey(Filesystem::readRandomCharacters(20)); - } - return parent::save(); - } - /* -( PhabricatorApplicationTransactionInterface )------------------------- */