mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Modernize "mailKey" on AlamnacService
Summary: Ref T13641. Ref T13065. Migrate and drop the onboard "mailKey" column for Almanac Services. Test Plan: Ran storage migration, got clean report, saw migrated value in mail properties table. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13641, T13065 Differential Revision: https://secure.phabricator.com/D21629
This commit is contained in:
parent
15c0c895a5
commit
fadb2bd52b
3 changed files with 32 additions and 8 deletions
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
$service_table = new AlmanacService();
|
||||
$service_conn = $service_table->establishConnection('w');
|
||||
|
||||
$properties_table = new PhabricatorMetaMTAMailProperties();
|
||||
$conn = $properties_table->establishConnection('w');
|
||||
|
||||
$iterator = new LiskRawMigrationIterator(
|
||||
$service_conn,
|
||||
$service_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_service
|
||||
DROP mailKey;
|
|
@ -14,7 +14,6 @@ final class AlmanacService
|
|||
|
||||
protected $name;
|
||||
protected $nameIndex;
|
||||
protected $mailKey;
|
||||
protected $viewPolicy;
|
||||
protected $editPolicy;
|
||||
protected $serviceType;
|
||||
|
@ -49,7 +48,6 @@ final class AlmanacService
|
|||
self::CONFIG_COLUMN_SCHEMA => array(
|
||||
'name' => 'text128',
|
||||
'nameIndex' => 'bytes12',
|
||||
'mailKey' => 'bytes20',
|
||||
'serviceType' => 'text64',
|
||||
),
|
||||
self::CONFIG_KEY_SCHEMA => array(
|
||||
|
@ -67,8 +65,8 @@ final class AlmanacService
|
|||
) + parent::getConfiguration();
|
||||
}
|
||||
|
||||
public function generatePHID() {
|
||||
return PhabricatorPHID::generateNewPHID(AlmanacServicePHIDType::TYPECONST);
|
||||
public function getPHIDType() {
|
||||
return AlmanacServicePHIDType::TYPECONST;
|
||||
}
|
||||
|
||||
public function save() {
|
||||
|
@ -76,10 +74,6 @@ final class AlmanacService
|
|||
|
||||
$this->nameIndex = PhabricatorHash::digestForIndex($this->getName());
|
||||
|
||||
if (!$this->mailKey) {
|
||||
$this->mailKey = Filesystem::readRandomCharacters(20);
|
||||
}
|
||||
|
||||
return parent::save();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue