mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 06:42:42 +01:00
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
This commit is contained in:
parent
8226b3c880
commit
86669ab54f
3 changed files with 35 additions and 14 deletions
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
$network_table = new AlmanacNetwork();
|
||||
$network_conn = $network_table->establishConnection('w');
|
||||
|
||||
$properties_table = new PhabricatorMetaMTAMailProperties();
|
||||
$conn = $properties_table->establishConnection('w');
|
||||
|
||||
$iterator = new LiskRawMigrationIterator(
|
||||
$network_conn,
|
||||
$network_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_network
|
||||
DROP mailKey;
|
|
@ -10,7 +10,6 @@ final class AlmanacNetwork
|
|||
PhabricatorConduitResultInterface {
|
||||
|
||||
protected $name;
|
||||
protected $mailKey;
|
||||
protected $viewPolicy;
|
||||
protected $editPolicy;
|
||||
|
||||
|
@ -25,8 +24,6 @@ final class AlmanacNetwork
|
|||
self::CONFIG_AUX_PHID => true,
|
||||
self::CONFIG_COLUMN_SCHEMA => array(
|
||||
'name' => 'sort128',
|
||||
'mailKey' => 'bytes20',
|
||||
|
||||
),
|
||||
self::CONFIG_KEY_SCHEMA => array(
|
||||
'key_name' => array(
|
||||
|
@ -37,20 +34,14 @@ final class AlmanacNetwork
|
|||
) + parent::getConfiguration();
|
||||
}
|
||||
|
||||
public function generatePHID() {
|
||||
return PhabricatorPHID::generateNewPHID(AlmanacNetworkPHIDType::TYPECONST);
|
||||
}
|
||||
|
||||
public function save() {
|
||||
if (!$this->mailKey) {
|
||||
$this->mailKey = Filesystem::readRandomCharacters(20);
|
||||
}
|
||||
|
||||
return parent::save();
|
||||
public function getPHIDType() {
|
||||
return AlmanacNetworkPHIDType::TYPECONST;
|
||||
}
|
||||
|
||||
public function getURI() {
|
||||
return '/almanac/network/'.$this->getID().'/';
|
||||
return urisprintf(
|
||||
'/almanac/network/%s/',
|
||||
$this->getID());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue