mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 06:42:42 +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:
parent
eeb009b4fa
commit
3267859aee
3 changed files with 32 additions and 11 deletions
|
@ -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());
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE {$NAMESPACE}_fund.fund_initiative
|
||||
DROP mailKey;
|
|
@ -22,7 +22,6 @@ final class FundInitiative extends FundDAO
|
|||
protected $editPolicy;
|
||||
protected $status;
|
||||
protected $totalAsCurrency;
|
||||
protected $mailKey;
|
||||
|
||||
private $projectPHIDs = self::ATTACHABLE;
|
||||
|
||||
|
@ -62,7 +61,6 @@ final class FundInitiative extends FundDAO
|
|||
'status' => 'text32',
|
||||
'merchantPHID' => 'phid?',
|
||||
'totalAsCurrency' => 'text64',
|
||||
'mailKey' => 'bytes20',
|
||||
),
|
||||
self::CONFIG_APPLICATION_SERIALIZERS => array(
|
||||
'totalAsCurrency' => new PhortuneCurrencySerializer(),
|
||||
|
@ -78,8 +76,8 @@ final class FundInitiative extends FundDAO
|
|||
) + parent::getConfiguration();
|
||||
}
|
||||
|
||||
public function generatePHID() {
|
||||
return PhabricatorPHID::generateNewPHID(FundInitiativePHIDType::TYPECONST);
|
||||
public function getPHIDType() {
|
||||
return FundInitiativePHIDType::TYPECONST;
|
||||
}
|
||||
|
||||
public function getMonogram() {
|
||||
|
@ -103,13 +101,6 @@ final class FundInitiative extends FundDAO
|
|||
return ($this->getStatus() == self::STATUS_CLOSED);
|
||||
}
|
||||
|
||||
public function save() {
|
||||
if (!$this->mailKey) {
|
||||
$this->mailKey = Filesystem::readRandomCharacters(20);
|
||||
}
|
||||
return parent::save();
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||
|
||||
|
|
Loading…
Reference in a new issue