mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 06:42:42 +01:00
Modernize "mailKey" on Almanac Namespaces
Summary: Ref T13065. Ref T13641. Migrate "mailKey" and drop the column. Test Plan: Ran "bin/storage upgrade", got a clean report, saw mail keys migrated to mail properties table. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13641, T13065 Differential Revision: https://secure.phabricator.com/D21631
This commit is contained in:
parent
7c0e33c34d
commit
8226b3c880
3 changed files with 35 additions and 10 deletions
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$namespace_table = new AlmanacNamespace();
|
||||||
|
$namespace_conn = $namespace_table->establishConnection('w');
|
||||||
|
|
||||||
|
$properties_table = new PhabricatorMetaMTAMailProperties();
|
||||||
|
$conn = $properties_table->establishConnection('w');
|
||||||
|
|
||||||
|
$iterator = new LiskRawMigrationIterator(
|
||||||
|
$namespace_conn,
|
||||||
|
$namespace_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_namespace
|
||||||
|
DROP mailKey;
|
|
@ -12,7 +12,6 @@ final class AlmanacNamespace
|
||||||
|
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $nameIndex;
|
protected $nameIndex;
|
||||||
protected $mailKey;
|
|
||||||
protected $viewPolicy;
|
protected $viewPolicy;
|
||||||
protected $editPolicy;
|
protected $editPolicy;
|
||||||
|
|
||||||
|
@ -28,7 +27,6 @@ final class AlmanacNamespace
|
||||||
self::CONFIG_COLUMN_SCHEMA => array(
|
self::CONFIG_COLUMN_SCHEMA => array(
|
||||||
'name' => 'text128',
|
'name' => 'text128',
|
||||||
'nameIndex' => 'bytes12',
|
'nameIndex' => 'bytes12',
|
||||||
'mailKey' => 'bytes20',
|
|
||||||
),
|
),
|
||||||
self::CONFIG_KEY_SCHEMA => array(
|
self::CONFIG_KEY_SCHEMA => array(
|
||||||
'key_nameindex' => array(
|
'key_nameindex' => array(
|
||||||
|
@ -42,9 +40,8 @@ final class AlmanacNamespace
|
||||||
) + parent::getConfiguration();
|
) + parent::getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generatePHID() {
|
public function getPHIDType() {
|
||||||
return PhabricatorPHID::generateNewPHID(
|
return AlmanacNamespacePHIDType::TYPECONST;
|
||||||
AlmanacNamespacePHIDType::TYPECONST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save() {
|
public function save() {
|
||||||
|
@ -52,15 +49,13 @@ final class AlmanacNamespace
|
||||||
|
|
||||||
$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();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURI() {
|
public function getURI() {
|
||||||
return '/almanac/namespace/view/'.$this->getName().'/';
|
return urisprintf(
|
||||||
|
'/almanac/namespace/view/%s/',
|
||||||
|
$this->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNameLength() {
|
public function getNameLength() {
|
||||||
|
|
Loading…
Reference in a new issue