diff --git a/resources/sql/autopatches/20210316.almanac.01.device-mailkey.php b/resources/sql/autopatches/20210316.almanac.01.device-mailkey.php new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20210316.almanac.01.device-mailkey.php @@ -0,0 +1,28 @@ +establishConnection('w'); + +$properties_table = new PhabricatorMetaMTAMailProperties(); +$conn = $properties_table->establishConnection('w'); + +$iterator = new LiskRawMigrationIterator( + $device_conn, + $device_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.02.device-dropmailkey.sql b/resources/sql/autopatches/20210316.almanac.02.device-dropmailkey.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20210316.almanac.02.device-dropmailkey.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_almanac.almanac_device + DROP mailKey; diff --git a/src/applications/almanac/storage/AlmanacDevice.php b/src/applications/almanac/storage/AlmanacDevice.php --- a/src/applications/almanac/storage/AlmanacDevice.php +++ b/src/applications/almanac/storage/AlmanacDevice.php @@ -15,7 +15,6 @@ protected $name; protected $nameIndex; - protected $mailKey; protected $viewPolicy; protected $editPolicy; protected $isBoundToClusterService; @@ -36,7 +35,6 @@ self::CONFIG_COLUMN_SCHEMA => array( 'name' => 'text128', 'nameIndex' => 'bytes12', - 'mailKey' => 'bytes20', 'isBoundToClusterService' => 'bool', ), self::CONFIG_KEY_SCHEMA => array( @@ -60,10 +58,6 @@ $this->nameIndex = PhabricatorHash::digestForIndex($this->getName()); - if (!$this->mailKey) { - $this->mailKey = Filesystem::readRandomCharacters(20); - } - return parent::save(); }