1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00

Remove on-object mailkeys from Phriction

Summary: Depends on D19619. Ref T13065. Ref T13077. Migrate Phriction mail keys to the new infrastructure and drop the column.

Test Plan: Ran migrations, spot-checked the database.

Reviewers: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13077, T13065

Differential Revision: https://secure.phabricator.com/D19620
This commit is contained in:
epriestley 2018-08-29 08:22:53 -07:00
parent 64cee4a902
commit 50f4adef64
3 changed files with 31 additions and 12 deletions

View file

@ -0,0 +1,26 @@
<?php
$document_table = new PhrictionDocument();
$document_conn = $document_table->establishConnection('w');
$document_name = $document_table->getTableName();
$properties_table = new PhabricatorMetaMTAMailProperties();
$conn = $properties_table->establishConnection('w');
$iterator = new LiskRawMigrationIterator($document_conn, $document_name);
foreach ($iterator as $row) {
queryfx(
$conn,
'INSERT IGNORE INTO %T
(objectPHID, mailProperties, dateCreated, dateModified)
VALUES
(%s, %s, %d, %d)',
$properties_table->getTableName(),
$row['phid'],
phutil_json_encode(
array(
'mailKey' => $row['mailKey'],
)),
PhabricatorTime::getNow(),
PhabricatorTime::getNow());
}

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_phriction.phriction_document
DROP mailKey;

View file

@ -19,7 +19,6 @@ final class PhrictionDocument extends PhrictionDAO
protected $depth;
protected $contentPHID;
protected $status;
protected $mailKey;
protected $viewPolicy;
protected $editPolicy;
protected $spacePHID;
@ -36,7 +35,6 @@ final class PhrictionDocument extends PhrictionDAO
'slug' => 'sort128',
'depth' => 'uint32',
'status' => 'text32',
'mailKey' => 'bytes20',
'editedEpoch' => 'epoch',
),
self::CONFIG_KEY_SCHEMA => array(
@ -95,13 +93,6 @@ final class PhrictionDocument extends PhrictionDAO
return $document;
}
public function save() {
if (!$this->getMailKey()) {
$this->setMailKey(Filesystem::readRandomCharacters(20));
}
return parent::save();
}
public static function getSlugURI($slug, $type = 'document') {
static $types = array(
'document' => '/w/',
@ -329,9 +320,9 @@ final class PhrictionDocument extends PhrictionDAO
/* -( PhabricatorPolicyCodexInterface )------------------------------------ */
public function newPolicyCodex() {
return new PhrictionDocumentPolicyCodex();
}
public function newPolicyCodex() {
return new PhrictionDocumentPolicyCodex();
}
}