1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00
phorge-phorge/resources/sql/patches/20130926.dinline.php
Joshua Spence 97a8700e45 Rename PHIDType classes
Summary: Ref T5655. Rename `PhabricatorPHIDType` subclasses for clarity (see discussion in D9839). I'm not too keen on some of the resulting class names, so feel free to suggest alternatives.

Test Plan: Ran unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin, hach-que

Maniphest Tasks: T5655

Differential Revision: https://secure.phabricator.com/D9986
2014-07-24 08:05:46 +10:00

90 lines
2.3 KiB
PHP

<?php
$revision_table = new DifferentialRevision();
$conn_w = $revision_table->establishConnection('w');
$conn_w->openTransaction();
$src_table = 'differential_inlinecomment';
$dst_table = 'differential_transaction_comment';
echo "Migrating Differential inline comments to new format...\n";
$content_source = PhabricatorContentSource::newForSource(
PhabricatorContentSource::SOURCE_LEGACY,
array())->serialize();
$rows = new LiskRawMigrationIterator($conn_w, $src_table);
foreach ($rows as $row) {
$id = $row['id'];
$revision_id = $row['revisionID'];
echo "Migrating inline #{$id} (D{$revision_id})...\n";
$revision_row = queryfx_one(
$conn_w,
'SELECT phid FROM %T WHERE id = %d',
$revision_table->getTableName(),
$revision_id);
if (!$revision_row) {
continue;
}
$revision_phid = $revision_row['phid'];
if ($row['commentID']) {
$xaction_phid = PhabricatorPHID::generateNewPHID(
PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST,
DifferentialRevisionPHIDType::TYPECONST);
} else {
$xaction_phid = null;
}
$comment_phid = PhabricatorPHID::generateNewPHID(
PhabricatorPHIDConstants::PHID_TYPE_XCMT,
DifferentialRevisionPHIDType::TYPECONST);
queryfx(
$conn_w,
'INSERT IGNORE INTO %T
(id, phid, transactionPHID, authorPHID, viewPolicy, editPolicy,
commentVersion, content, contentSource, isDeleted,
dateCreated, dateModified, revisionPHID, changesetID,
isNewFile, lineNumber, lineLength, hasReplies, legacyCommentID)
VALUES (%d, %s, %ns, %s, %s, %s,
%d, %s, %s, %d,
%d, %d, %s, %nd,
%d, %d, %d, %d, %nd)',
$dst_table,
// id, phid, transactionPHID, authorPHID, viewPolicy, editPolicy
$row['id'],
$comment_phid,
$xaction_phid,
$row['authorPHID'],
'public',
$row['authorPHID'],
// commentVersion, content, contentSource, isDeleted
1,
$row['content'],
$content_source,
0,
// dateCreated, dateModified, revisionPHID, changesetID
$row['dateCreated'],
$row['dateModified'],
$revision_phid,
$row['changesetID'],
// isNewFile, lineNumber, lineLength, hasReplies, legacyCommentID
$row['isNewFile'],
$row['lineNumber'],
$row['lineLength'],
0,
$row['commentID']);
}
$conn_w->saveTransaction();
echo "Done.\n";