1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 08:12:40 +01:00

Modernize "mailKey" on Fund initiatives

Summary: Ref T13065. Migrate "mailKey" and drop the column.

Test Plan: Ran "bin/storage upgrade", got a clean upgrade, saw migrated values in mail properties table.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13065

Differential Revision: https://secure.phabricator.com/D21634
This commit is contained in:
epriestley 2021-03-16 15:21:35 -07:00
parent eeb009b4fa
commit 3267859aee
3 changed files with 32 additions and 11 deletions

View file

@ -0,0 +1,28 @@
<?php
$initiative_table = new FundInitiative();
$initiative_conn = $initiative_table->establishConnection('w');
$properties_table = new PhabricatorMetaMTAMailProperties();
$conn = $properties_table->establishConnection('w');
$iterator = new LiskRawMigrationIterator(
$initiative_conn,
$initiative_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());
}

View file

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

View file

@ -22,7 +22,6 @@ final class FundInitiative extends FundDAO
protected $editPolicy; protected $editPolicy;
protected $status; protected $status;
protected $totalAsCurrency; protected $totalAsCurrency;
protected $mailKey;
private $projectPHIDs = self::ATTACHABLE; private $projectPHIDs = self::ATTACHABLE;
@ -62,7 +61,6 @@ final class FundInitiative extends FundDAO
'status' => 'text32', 'status' => 'text32',
'merchantPHID' => 'phid?', 'merchantPHID' => 'phid?',
'totalAsCurrency' => 'text64', 'totalAsCurrency' => 'text64',
'mailKey' => 'bytes20',
), ),
self::CONFIG_APPLICATION_SERIALIZERS => array( self::CONFIG_APPLICATION_SERIALIZERS => array(
'totalAsCurrency' => new PhortuneCurrencySerializer(), 'totalAsCurrency' => new PhortuneCurrencySerializer(),
@ -78,8 +76,8 @@ final class FundInitiative extends FundDAO
) + parent::getConfiguration(); ) + parent::getConfiguration();
} }
public function generatePHID() { public function getPHIDType() {
return PhabricatorPHID::generateNewPHID(FundInitiativePHIDType::TYPECONST); return FundInitiativePHIDType::TYPECONST;
} }
public function getMonogram() { public function getMonogram() {
@ -103,13 +101,6 @@ final class FundInitiative extends FundDAO
return ($this->getStatus() == self::STATUS_CLOSED); return ($this->getStatus() == self::STATUS_CLOSED);
} }
public function save() {
if (!$this->mailKey) {
$this->mailKey = Filesystem::readRandomCharacters(20);
}
return parent::save();
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */ /* -( PhabricatorPolicyInterface )----------------------------------------- */