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

MetaMTA - save actorPHID as its own column

Summary: Ref T5791. This should make performance snappy wrt policy checks in some future diff where the Query is updated and in use somewhere in the application.

Test Plan: ran `./bin/storage upgrade`. commented on a task and saw actorPHID populated correctly in underlying MetaMTAMail object database entry

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5791

Differential Revision: https://secure.phabricator.com/D13396
This commit is contained in:
Bob Trahan 2015-06-22 14:14:21 -07:00
parent ea5462fb60
commit 4be568d346
4 changed files with 41 additions and 0 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_metamta.metamta_mail
ADD actorPHID VARBINARY(64) AFTER phid;

View file

@ -0,0 +1,27 @@
<?php
$table = new PhabricatorMetaMTAMail();
$conn_w = $table->establishConnection('w');
echo pht('Assigning actorPHIDs to mails...')."\n";
foreach (new LiskMigrationIterator($table) as $mail) {
$id = $mail->getID();
echo pht('Updating mail %d...', $id)."\n";
if ($mail->getActorPHID()) {
continue;
}
$actor_phid = $mail->getFrom();
if ($actor_phid === null) {
continue;
}
queryfx(
$conn_w,
'UPDATE %T SET actorPHID = %s WHERE id = %d',
$table->getTableName(),
$actor_phid,
$id);
}
echo pht('Done.')."\n";

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_metamta.metamta_mail
ADD KEY `key_actorPHID` (actorPHID);

View file

@ -14,6 +14,7 @@ final class PhabricatorMetaMTAMail
const RETRY_DELAY = 5;
protected $actorPHID;
protected $parameters;
protected $status;
protected $message;
@ -36,6 +37,7 @@ final class PhabricatorMetaMTAMail
'parameters' => self::SERIALIZATION_JSON,
),
self::CONFIG_COLUMN_SCHEMA => array(
'actorPHID' => 'phid?',
'status' => 'text32',
'relatedPHID' => 'phid?',
@ -47,6 +49,9 @@ final class PhabricatorMetaMTAMail
'status' => array(
'columns' => array('status'),
),
'key_actorPHID' => array(
'columns' => array('actorPHID'),
),
'relatedPHID' => array(
'columns' => array('relatedPHID'),
),
@ -219,9 +224,14 @@ final class PhabricatorMetaMTAMail
public function setFrom($from) {
$this->setParam('from', $from);
$this->setActorPHID($from);
return $this;
}
public function getFrom() {
return $this->getParam('from');
}
public function setRawFrom($raw_email, $raw_name) {
$this->setParam('raw-from', array($raw_email, $raw_name));
return $this;