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

Modernize "mailKey" for Calendar Event

Summary: Ref T13065. Migrate "mailKey" and drop the column.

Test Plan: Ran "bin/storage upgrade", got a clean report, saw migrated data in mail properties table.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13065

Differential Revision: https://secure.phabricator.com/D21633
This commit is contained in:
epriestley 2021-03-16 15:15:11 -07:00
parent 86669ab54f
commit eeb009b4fa
3 changed files with 32 additions and 9 deletions

View file

@ -0,0 +1,28 @@
<?php
$event_table = new PhabricatorCalendarEvent();
$event_conn = $event_table->establishConnection('w');
$properties_table = new PhabricatorMetaMTAMailProperties();
$conn = $properties_table->establishConnection('w');
$iterator = new LiskRawMigrationIterator(
$event_conn,
$event_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());
}

View file

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

View file

@ -24,7 +24,6 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
protected $isCancelled; protected $isCancelled;
protected $isAllDay; protected $isAllDay;
protected $icon; protected $icon;
protected $mailKey;
protected $isStub; protected $isStub;
protected $isRecurring = 0; protected $isRecurring = 0;
@ -360,10 +359,6 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
} }
public function save() { public function save() {
if (!$this->mailKey) {
$this->mailKey = Filesystem::readRandomCharacters(20);
}
$import_uid = $this->getImportUID(); $import_uid = $this->getImportUID();
if ($import_uid !== null) { if ($import_uid !== null) {
$index = PhabricatorHash::digestForIndex($import_uid); $index = PhabricatorHash::digestForIndex($import_uid);
@ -405,7 +400,6 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
'isCancelled' => 'bool', 'isCancelled' => 'bool',
'isAllDay' => 'bool', 'isAllDay' => 'bool',
'icon' => 'text32', 'icon' => 'text32',
'mailKey' => 'bytes20',
'isRecurring' => 'bool', 'isRecurring' => 'bool',
'seriesParentPHID' => 'phid?', 'seriesParentPHID' => 'phid?',
'instanceOfEventPHID' => 'phid?', 'instanceOfEventPHID' => 'phid?',
@ -442,9 +436,8 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
) + parent::getConfiguration(); ) + parent::getConfiguration();
} }
public function generatePHID() { public function getPHIDType() {
return PhabricatorPHID::generateNewPHID( return PhabricatorCalendarEventPHIDType::TYPECONST;
PhabricatorCalendarEventPHIDType::TYPECONST);
} }
public function getMonogram() { public function getMonogram() {