mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Modernize "mailKey" for Almanac Bindings
Summary: Ref T13065. Ref T13641. Migrate "mailKey" and drop the column. Test Plan: Ran "bin/storage upgrade", got a clean report and saw binding mail keys in the mail properties table. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13641, T13065 Differential Revision: https://secure.phabricator.com/D21630
This commit is contained in:
parent
fadb2bd52b
commit
7c0e33c34d
3 changed files with 35 additions and 12 deletions
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$binding_table = new AlmanacBinding();
|
||||||
|
$binding_conn = $binding_table->establishConnection('w');
|
||||||
|
|
||||||
|
$properties_table = new PhabricatorMetaMTAMailProperties();
|
||||||
|
$conn = $properties_table->establishConnection('w');
|
||||||
|
|
||||||
|
$iterator = new LiskRawMigrationIterator(
|
||||||
|
$binding_conn,
|
||||||
|
$binding_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_binding
|
||||||
|
DROP mailKey;
|
|
@ -13,7 +13,6 @@ final class AlmanacBinding
|
||||||
protected $servicePHID;
|
protected $servicePHID;
|
||||||
protected $devicePHID;
|
protected $devicePHID;
|
||||||
protected $interfacePHID;
|
protected $interfacePHID;
|
||||||
protected $mailKey;
|
|
||||||
protected $isDisabled;
|
protected $isDisabled;
|
||||||
|
|
||||||
private $service = self::ATTACHABLE;
|
private $service = self::ATTACHABLE;
|
||||||
|
@ -33,7 +32,6 @@ final class AlmanacBinding
|
||||||
return array(
|
return array(
|
||||||
self::CONFIG_AUX_PHID => true,
|
self::CONFIG_AUX_PHID => true,
|
||||||
self::CONFIG_COLUMN_SCHEMA => array(
|
self::CONFIG_COLUMN_SCHEMA => array(
|
||||||
'mailKey' => 'bytes20',
|
|
||||||
'isDisabled' => 'bool',
|
'isDisabled' => 'bool',
|
||||||
),
|
),
|
||||||
self::CONFIG_KEY_SCHEMA => array(
|
self::CONFIG_KEY_SCHEMA => array(
|
||||||
|
@ -51,15 +49,8 @@ final class AlmanacBinding
|
||||||
) + parent::getConfiguration();
|
) + parent::getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generatePHID() {
|
public function getPHIDType() {
|
||||||
return PhabricatorPHID::generateNewPHID(AlmanacBindingPHIDType::TYPECONST);
|
return AlmanacBindingPHIDType::TYPECONST;
|
||||||
}
|
|
||||||
|
|
||||||
public function save() {
|
|
||||||
if (!$this->mailKey) {
|
|
||||||
$this->mailKey = Filesystem::readRandomCharacters(20);
|
|
||||||
}
|
|
||||||
return parent::save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName() {
|
||||||
|
@ -67,7 +58,9 @@ final class AlmanacBinding
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURI() {
|
public function getURI() {
|
||||||
return '/almanac/binding/'.$this->getID().'/';
|
return urisprintf(
|
||||||
|
'/almanac/binding/%s/',
|
||||||
|
$this->getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getService() {
|
public function getService() {
|
||||||
|
|
Loading…
Reference in a new issue