diff --git a/resources/sql/autopatches/20181220.pholio.01.mailkey.php b/resources/sql/autopatches/20181220.pholio.01.mailkey.php new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20181220.pholio.01.mailkey.php @@ -0,0 +1,28 @@ +establishConnection('w'); + +$properties_table = new PhabricatorMetaMTAMailProperties(); +$conn = $properties_table->establishConnection('w'); + +$iterator = new LiskRawMigrationIterator( + $mock_conn, + $mock_table->getTableName()); + +foreach ($iterator as $row) { + queryfx( + $conn, + 'INSERT IGNORE INTO %T + (objectPHID, mailProperties, dateCreated, dateModified) + VALUES + (%s, %s, %d, %d)', + $properties_table->getTableName(), + $row['phid'], + phutil_json_encode( + array( + 'mailKey' => $row['mailKey'], + )), + PhabricatorTime::getNow(), + PhabricatorTime::getNow()); +} diff --git a/resources/sql/autopatches/20181220.pholio.02.dropmailkey.sql b/resources/sql/autopatches/20181220.pholio.02.dropmailkey.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20181220.pholio.02.dropmailkey.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_pholio.pholio_mock + DROP mailKey; diff --git a/src/applications/pholio/storage/PholioMock.php b/src/applications/pholio/storage/PholioMock.php --- a/src/applications/pholio/storage/PholioMock.php +++ b/src/applications/pholio/storage/PholioMock.php @@ -25,7 +25,6 @@ protected $name; protected $description; protected $coverPHID; - protected $mailKey; protected $status; protected $spacePHID; @@ -65,15 +64,9 @@ self::CONFIG_COLUMN_SCHEMA => array( 'name' => 'text128', 'description' => 'text', - 'mailKey' => 'bytes20', 'status' => 'text12', ), self::CONFIG_KEY_SCHEMA => array( - 'key_phid' => null, - 'phid' => array( - 'columns' => array('phid'), - 'unique' => true, - ), 'authorPHID' => array( 'columns' => array('authorPHID'), ), @@ -81,15 +74,8 @@ ) + parent::getConfiguration(); } - public function generatePHID() { - return PhabricatorPHID::generateNewPHID('MOCK'); - } - - public function save() { - if (!$this->getMailKey()) { - $this->setMailKey(Filesystem::readRandomCharacters(20)); - } - return parent::save(); + public function getPHIDType() { + return PholioMockPHIDType::TYPECONST; } public function attachImages(array $images) {