1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

Remove explicit "mailKey" from Owners packages

Summary:
Depends on D19426. Ref T13130. Ref T13065. While I'm making changes to Owners for "Ignore generated paths", clean up the "mailKey" column.

We recently (D19399) added code to automatically generate and manage mail keys so we don't need a ton of `mailKey` properties in the future. Migrate existing mail keys and blow away the explicit column on packages.

Test Plan: Ran migration, manually looked at the database and saw sensible data. Edited a package to send some mail, which looked good.

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13130, T13065

Differential Revision: https://secure.phabricator.com/D19427
This commit is contained in:
epriestley 2018-05-04 13:41:03 -07:00
parent 5e2af4b9b5
commit dc510354c3
3 changed files with 30 additions and 13 deletions

View file

@ -0,0 +1,26 @@
<?php
$packages_table = new PhabricatorOwnersPackage();
$packages_conn = $packages_table->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());
}

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_owners.owners_package
DROP mailKey;

View file

@ -16,7 +16,6 @@ final class PhabricatorOwnersPackage
protected $auditingEnabled;
protected $autoReview;
protected $description;
protected $mailKey;
protected $status;
protected $viewPolicy;
protected $editPolicy;
@ -122,7 +121,6 @@ final class PhabricatorOwnersPackage
'name' => 'sort',
'description' => 'text',
'auditingEnabled' => 'bool',
'mailKey' => 'bytes20',
'status' => 'text32',
'autoReview' => 'text32',
'dominion' => 'text32',
@ -130,17 +128,8 @@ final class PhabricatorOwnersPackage
) + 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() {