mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 06:42:42 +01:00
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
This commit is contained in:
parent
42c0c0e3d2
commit
c3e6db6f0b
3 changed files with 30 additions and 6 deletions
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$device_table = new AlmanacDevice();
|
||||||
|
$device_conn = $device_table->establishConnection('w');
|
||||||
|
|
||||||
|
$properties_table = new PhabricatorMetaMTAMailProperties();
|
||||||
|
$conn = $properties_table->establishConnection('w');
|
||||||
|
|
||||||
|
$iterator = new LiskRawMigrationIterator(
|
||||||
|
$device_conn,
|
||||||
|
$device_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}_almanac.almanac_device
|
||||||
|
DROP mailKey;
|
|
@ -15,7 +15,6 @@ final class AlmanacDevice
|
||||||
|
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $nameIndex;
|
protected $nameIndex;
|
||||||
protected $mailKey;
|
|
||||||
protected $viewPolicy;
|
protected $viewPolicy;
|
||||||
protected $editPolicy;
|
protected $editPolicy;
|
||||||
protected $isBoundToClusterService;
|
protected $isBoundToClusterService;
|
||||||
|
@ -36,7 +35,6 @@ final class AlmanacDevice
|
||||||
self::CONFIG_COLUMN_SCHEMA => array(
|
self::CONFIG_COLUMN_SCHEMA => array(
|
||||||
'name' => 'text128',
|
'name' => 'text128',
|
||||||
'nameIndex' => 'bytes12',
|
'nameIndex' => 'bytes12',
|
||||||
'mailKey' => 'bytes20',
|
|
||||||
'isBoundToClusterService' => 'bool',
|
'isBoundToClusterService' => 'bool',
|
||||||
),
|
),
|
||||||
self::CONFIG_KEY_SCHEMA => array(
|
self::CONFIG_KEY_SCHEMA => array(
|
||||||
|
@ -60,10 +58,6 @@ final class AlmanacDevice
|
||||||
|
|
||||||
$this->nameIndex = PhabricatorHash::digestForIndex($this->getName());
|
$this->nameIndex = PhabricatorHash::digestForIndex($this->getName());
|
||||||
|
|
||||||
if (!$this->mailKey) {
|
|
||||||
$this->mailKey = Filesystem::readRandomCharacters(20);
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::save();
|
return parent::save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue