Skip to content

Commit 3267859

Browse files
author
epriestley
committedMar 16, 2021
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
1 parent eeb009b commit 3267859

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
$initiative_table = new FundInitiative();
4+
$initiative_conn = $initiative_table->establishConnection('w');
5+
6+
$properties_table = new PhabricatorMetaMTAMailProperties();
7+
$conn = $properties_table->establishConnection('w');
8+
9+
$iterator = new LiskRawMigrationIterator(
10+
$initiative_conn,
11+
$initiative_table->getTableName());
12+
13+
foreach ($iterator as $row) {
14+
queryfx(
15+
$conn,
16+
'INSERT IGNORE INTO %R
17+
(objectPHID, mailProperties, dateCreated, dateModified)
18+
VALUES
19+
(%s, %s, %d, %d)',
20+
$properties_table,
21+
$row['phid'],
22+
phutil_json_encode(
23+
array(
24+
'mailKey' => $row['mailKey'],
25+
)),
26+
PhabricatorTime::getNow(),
27+
PhabricatorTime::getNow());
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE {$NAMESPACE}_fund.fund_initiative
2+
DROP mailKey;

‎src/applications/fund/storage/FundInitiative.php

+2-11
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ final class FundInitiative extends FundDAO
2222
protected $editPolicy;
2323
protected $status;
2424
protected $totalAsCurrency;
25-
protected $mailKey;
2625

2726
private $projectPHIDs = self::ATTACHABLE;
2827

@@ -62,7 +61,6 @@ protected function getConfiguration() {
6261
'status' => 'text32',
6362
'merchantPHID' => 'phid?',
6463
'totalAsCurrency' => 'text64',
65-
'mailKey' => 'bytes20',
6664
),
6765
self::CONFIG_APPLICATION_SERIALIZERS => array(
6866
'totalAsCurrency' => new PhortuneCurrencySerializer(),
@@ -78,8 +76,8 @@ protected function getConfiguration() {
7876
) + parent::getConfiguration();
7977
}
8078

81-
public function generatePHID() {
82-
return PhabricatorPHID::generateNewPHID(FundInitiativePHIDType::TYPECONST);
79+
public function getPHIDType() {
80+
return FundInitiativePHIDType::TYPECONST;
8381
}
8482

8583
public function getMonogram() {
@@ -103,13 +101,6 @@ public function isClosed() {
103101
return ($this->getStatus() == self::STATUS_CLOSED);
104102
}
105103

106-
public function save() {
107-
if (!$this->mailKey) {
108-
$this->mailKey = Filesystem::readRandomCharacters(20);
109-
}
110-
return parent::save();
111-
}
112-
113104

114105
/* -( PhabricatorPolicyInterface )----------------------------------------- */
115106

0 commit comments

Comments
 (0)
Failed to load comments.