Skip to content

Commit c3e6db6

Browse files
author
epriestley
committedMar 16, 2021
Migrate Almanac Device "mailKey" to modern storage
Summary: Ref T13065. See similar changes attached to that task. Test Plan: Ran migration, got a clean database state, saw mail keys populate in mail property table. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13065, T13641 Differential Revision: https://secure.phabricator.com/D21625
1 parent 42c0c0e commit c3e6db6

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
$device_table = new AlmanacDevice();
4+
$device_conn = $device_table->establishConnection('w');
5+
6+
$properties_table = new PhabricatorMetaMTAMailProperties();
7+
$conn = $properties_table->establishConnection('w');
8+
9+
$iterator = new LiskRawMigrationIterator(
10+
$device_conn,
11+
$device_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_device
2+
DROP mailKey;

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

-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ final class AlmanacDevice
1515

1616
protected $name;
1717
protected $nameIndex;
18-
protected $mailKey;
1918
protected $viewPolicy;
2019
protected $editPolicy;
2120
protected $isBoundToClusterService;
@@ -36,7 +35,6 @@ protected function getConfiguration() {
3635
self::CONFIG_COLUMN_SCHEMA => array(
3736
'name' => 'text128',
3837
'nameIndex' => 'bytes12',
39-
'mailKey' => 'bytes20',
4038
'isBoundToClusterService' => 'bool',
4139
),
4240
self::CONFIG_KEY_SCHEMA => array(
@@ -60,10 +58,6 @@ public function save() {
6058

6159
$this->nameIndex = PhabricatorHash::digestForIndex($this->getName());
6260

63-
if (!$this->mailKey) {
64-
$this->mailKey = Filesystem::readRandomCharacters(20);
65-
}
66-
6761
return parent::save();
6862
}
6963

0 commit comments

Comments
 (0)
Failed to load comments.