mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
Php schema patch to update channel id's of past events.
Summary: Php schema patch to update channel id's of past events. Test Plan: Having some proxy issues here due to which connection is timing out and bot is not able to log into IRC. Bot connects to IRC in my home though ! So I wasn't able to quite to test this by running storage upgrade. Reviewers: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D5000
This commit is contained in:
parent
cd41b834f7
commit
61c26463bc
2 changed files with 54 additions and 0 deletions
50
resources/sql/patches/20130218.updatechannelid.php
Normal file
50
resources/sql/patches/20130218.updatechannelid.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
echo "Updating channel IDs of previous chatlog events...\n";
|
||||
$event_table = new PhabricatorChatLogEvent();
|
||||
$channel_table = new PhabricatorChatLogChannel();
|
||||
|
||||
$event_table->openTransaction();
|
||||
$channel_table->openTransaction();
|
||||
|
||||
$event_table->beginReadLocking();
|
||||
$channel_table->beginReadLocking();
|
||||
|
||||
$events = new LiskMigrationIterator($event_table);
|
||||
|
||||
foreach ($events as $event) {
|
||||
if ($event->getChannelID()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$matched = $channel_table->loadOneWhere(
|
||||
"channelName = %s AND serviceName = %s AND serviceType = %s",
|
||||
$event->getChannel(),
|
||||
'',
|
||||
'');
|
||||
|
||||
if (!$matched) {
|
||||
$matched = id(new PhabricatorChatLogChannel())
|
||||
->setChannelName($event->getChannel())
|
||||
->setServiceType('')
|
||||
->setServiceName('')
|
||||
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
|
||||
->setEditPolicy(PhabricatorPolicies::POLICY_USER)
|
||||
->save();
|
||||
}
|
||||
|
||||
queryfx(
|
||||
$event->establishConnection('w'),
|
||||
'UPDATE %T SET channelID = %d WHERE id = %d',
|
||||
$event->getTableName(),
|
||||
$matched->getID(),
|
||||
$event->getID());
|
||||
}
|
||||
|
||||
$event_table->endReadLocking();
|
||||
$channel_table->endReadLocking();
|
||||
|
||||
$event_table->saveTransaction();
|
||||
$channel_table->saveTransaction();
|
||||
|
||||
echo "\nDone.\n";
|
|
@ -1129,6 +1129,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
|
|||
'type' => 'sql',
|
||||
'name' => $this->getPatchPath('20130217.cachettl.sql'),
|
||||
),
|
||||
'20130218.updatechannelid.php' => array(
|
||||
'type' => 'php',
|
||||
'name' => $this->getPatchPath('20130218.updatechannelid.php'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue