Skip to content

Commit 86669ab

Browse files
author
epriestley
committedMar 16, 2021
Modernize "mailKey" for Almanac Networks
Summary: Ref T13065. Ref T13641. Migrate "mailKey" and drop the column. Test Plan: Ran "bin/storage upgrade", got a clean report, saw keys migrate in mail properties table. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13641, T13065 Differential Revision: https://secure.phabricator.com/D21632
1 parent 8226b3c commit 86669ab

File tree

3 files changed

+35
-14
lines changed

3 files changed

+35
-14
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
$network_table = new AlmanacNetwork();
4+
$network_conn = $network_table->establishConnection('w');
5+
6+
$properties_table = new PhabricatorMetaMTAMailProperties();
7+
$conn = $properties_table->establishConnection('w');
8+
9+
$iterator = new LiskRawMigrationIterator(
10+
$network_conn,
11+
$network_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}_almanac.almanac_network
2+
DROP mailKey;

‎src/applications/almanac/storage/AlmanacNetwork.php

+5-14
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ final class AlmanacNetwork
1010
PhabricatorConduitResultInterface {
1111

1212
protected $name;
13-
protected $mailKey;
1413
protected $viewPolicy;
1514
protected $editPolicy;
1615

@@ -25,8 +24,6 @@ protected function getConfiguration() {
2524
self::CONFIG_AUX_PHID => true,
2625
self::CONFIG_COLUMN_SCHEMA => array(
2726
'name' => 'sort128',
28-
'mailKey' => 'bytes20',
29-
3027
),
3128
self::CONFIG_KEY_SCHEMA => array(
3229
'key_name' => array(
@@ -37,20 +34,14 @@ protected function getConfiguration() {
3734
) + parent::getConfiguration();
3835
}
3936

40-
public function generatePHID() {
41-
return PhabricatorPHID::generateNewPHID(AlmanacNetworkPHIDType::TYPECONST);
42-
}
43-
44-
public function save() {
45-
if (!$this->mailKey) {
46-
$this->mailKey = Filesystem::readRandomCharacters(20);
47-
}
48-
49-
return parent::save();
37+
public function getPHIDType() {
38+
return AlmanacNetworkPHIDType::TYPECONST;
5039
}
5140

5241
public function getURI() {
53-
return '/almanac/network/'.$this->getID().'/';
42+
return urisprintf(
43+
'/almanac/network/%s/',
44+
$this->getID());
5445
}
5546

5647

0 commit comments

Comments
 (0)
Failed to load comments.