diff --git a/resources/sql/autopatches/20210316.almanac.07.binding-mailkey.php b/resources/sql/autopatches/20210316.almanac.07.binding-mailkey.php new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20210316.almanac.07.binding-mailkey.php @@ -0,0 +1,28 @@ +establishConnection('w'); + +$properties_table = new PhabricatorMetaMTAMailProperties(); +$conn = $properties_table->establishConnection('w'); + +$iterator = new LiskRawMigrationIterator( + $binding_conn, + $binding_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/20210316.almanac.08.binding-dropmailkey.sql b/resources/sql/autopatches/20210316.almanac.08.binding-dropmailkey.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20210316.almanac.08.binding-dropmailkey.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_almanac.almanac_binding + DROP mailKey; diff --git a/src/applications/almanac/storage/AlmanacBinding.php b/src/applications/almanac/storage/AlmanacBinding.php --- a/src/applications/almanac/storage/AlmanacBinding.php +++ b/src/applications/almanac/storage/AlmanacBinding.php @@ -13,7 +13,6 @@ protected $servicePHID; protected $devicePHID; protected $interfacePHID; - protected $mailKey; protected $isDisabled; private $service = self::ATTACHABLE; @@ -33,7 +32,6 @@ return array( self::CONFIG_AUX_PHID => true, self::CONFIG_COLUMN_SCHEMA => array( - 'mailKey' => 'bytes20', 'isDisabled' => 'bool', ), self::CONFIG_KEY_SCHEMA => array( @@ -51,15 +49,8 @@ ) + parent::getConfiguration(); } - public function generatePHID() { - return PhabricatorPHID::generateNewPHID(AlmanacBindingPHIDType::TYPECONST); - } - - public function save() { - if (!$this->mailKey) { - $this->mailKey = Filesystem::readRandomCharacters(20); - } - return parent::save(); + public function getPHIDType() { + return AlmanacBindingPHIDType::TYPECONST; } public function getName() { @@ -67,7 +58,9 @@ } public function getURI() { - return '/almanac/binding/'.$this->getID().'/'; + return urisprintf( + '/almanac/binding/%s/', + $this->getID()); } public function getService() {