diff --git a/resources/sql/autopatches/20180504.owners.01.mailkey.php b/resources/sql/autopatches/20180504.owners.01.mailkey.php new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20180504.owners.01.mailkey.php @@ -0,0 +1,26 @@ +establishConnection('w'); +$packages_name = $packages_table->getTableName(); + +$properties_table = new PhabricatorMetaMTAMailProperties(); +$conn = $properties_table->establishConnection('w'); + +$iterator = new LiskRawMigrationIterator($packages_conn, $packages_name); +foreach ($iterator as $package) { + queryfx( + $conn, + 'INSERT IGNORE INTO %T + (objectPHID, mailProperties, dateCreated, dateModified) + VALUES + (%s, %s, %d, %d)', + $properties_table->getTableName(), + $package['phid'], + phutil_json_encode( + array( + 'mailKey' => $package['mailKey'], + )), + PhabricatorTime::getNow(), + PhabricatorTime::getNow()); +} diff --git a/resources/sql/autopatches/20180504.owners.02.rmkey.sql b/resources/sql/autopatches/20180504.owners.02.rmkey.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20180504.owners.02.rmkey.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_owners.owners_package + DROP mailKey; diff --git a/src/applications/owners/storage/PhabricatorOwnersPackage.php b/src/applications/owners/storage/PhabricatorOwnersPackage.php --- a/src/applications/owners/storage/PhabricatorOwnersPackage.php +++ b/src/applications/owners/storage/PhabricatorOwnersPackage.php @@ -16,7 +16,6 @@ protected $auditingEnabled; protected $autoReview; protected $description; - protected $mailKey; protected $status; protected $viewPolicy; protected $editPolicy; @@ -122,7 +121,6 @@ 'name' => 'sort', 'description' => 'text', 'auditingEnabled' => 'bool', - 'mailKey' => 'bytes20', 'status' => 'text32', 'autoReview' => 'text32', 'dominion' => 'text32', @@ -130,17 +128,8 @@ ) + parent::getConfiguration(); } - public function generatePHID() { - return PhabricatorPHID::generateNewPHID( - PhabricatorOwnersPackagePHIDType::TYPECONST); - } - - public function save() { - if (!$this->getMailKey()) { - $this->setMailKey(Filesystem::readRandomCharacters(20)); - } - - return parent::save(); + public function getPHIDType() { + return PhabricatorOwnersPackagePHIDType::TYPECONST; } public function isArchived() {