@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

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

+30 -6
+28
resources/sql/autopatches/20210316.almanac.01.device-mailkey.php
··· 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 + }
+2
resources/sql/autopatches/20210316.almanac.02.device-dropmailkey.sql
··· 1 + ALTER TABLE {$NAMESPACE}_almanac.almanac_device 2 + DROP mailKey;
-6
src/applications/almanac/storage/AlmanacDevice.php
··· 15 15 16 16 protected $name; 17 17 protected $nameIndex; 18 - protected $mailKey; 19 18 protected $viewPolicy; 20 19 protected $editPolicy; 21 20 protected $isBoundToClusterService; ··· 36 35 self::CONFIG_COLUMN_SCHEMA => array( 37 36 'name' => 'text128', 38 37 'nameIndex' => 'bytes12', 39 - 'mailKey' => 'bytes20', 40 38 'isBoundToClusterService' => 'bool', 41 39 ), 42 40 self::CONFIG_KEY_SCHEMA => array( ··· 59 57 AlmanacNames::validateName($this->getName()); 60 58 61 59 $this->nameIndex = PhabricatorHash::digestForIndex($this->getName()); 62 - 63 - if (!$this->mailKey) { 64 - $this->mailKey = Filesystem::readRandomCharacters(20); 65 - } 66 60 67 61 return parent::save(); 68 62 }