2014-02-11 20:34:15 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
$conn_w = id(new DifferentialRevision())->establishConnection('w');
|
|
|
|
$rows = new LiskRawMigrationIterator($conn_w, 'differential_comment');
|
|
|
|
|
|
|
|
$content_source = PhabricatorContentSource::newForSource(
|
|
|
|
PhabricatorContentSource::SOURCE_LEGACY,
|
|
|
|
array())->serialize();
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Migrating Differential comment text to modern storage...')."\n";
|
2014-02-11 20:34:15 +01:00
|
|
|
foreach ($rows as $row) {
|
|
|
|
$id = $row['id'];
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Migrating Differential comment %d...', $id)."\n";
|
2014-02-11 20:34:15 +01:00
|
|
|
if (!strlen($row['content'])) {
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Comment has no text, continuing.')."\n";
|
2014-02-11 20:34:15 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$revision = id(new DifferentialRevision())->load($row['revisionID']);
|
|
|
|
if (!$revision) {
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Comment has no valid revision, continuing.')."\n";
|
2014-02-11 20:34:15 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$revision_phid = $revision->getPHID();
|
|
|
|
|
|
|
|
$dst_table = 'differential_inline_comment';
|
|
|
|
|
|
|
|
$xaction_phid = PhabricatorPHID::generateNewPHID(
|
2014-07-24 00:05:46 +02:00
|
|
|
PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST,
|
|
|
|
DifferentialRevisionPHIDType::TYPECONST);
|
2014-02-11 20:34:15 +01:00
|
|
|
|
|
|
|
$comment_phid = PhabricatorPHID::generateNewPHID(
|
|
|
|
PhabricatorPHIDConstants::PHID_TYPE_XCMT,
|
2014-07-24 00:05:46 +02:00
|
|
|
DifferentialRevisionPHIDType::TYPECONST);
|
2014-02-11 20:34:15 +01:00
|
|
|
|
|
|
|
queryfx(
|
|
|
|
$conn_w,
|
|
|
|
'INSERT IGNORE INTO %T
|
|
|
|
(phid, transactionPHID, authorPHID, viewPolicy, editPolicy,
|
|
|
|
commentVersion, content, contentSource, isDeleted,
|
|
|
|
dateCreated, dateModified, revisionPHID, changesetID,
|
|
|
|
legacyCommentID)
|
|
|
|
VALUES (%s, %s, %s, %s, %s,
|
|
|
|
%d, %s, %s, %d,
|
|
|
|
%d, %d, %s, %nd,
|
|
|
|
%d)',
|
|
|
|
'differential_transaction_comment',
|
|
|
|
|
|
|
|
// phid, transactionPHID, authorPHID, viewPolicy, editPolicy
|
|
|
|
$comment_phid,
|
|
|
|
$xaction_phid,
|
|
|
|
$row['authorPHID'],
|
|
|
|
'public',
|
|
|
|
$row['authorPHID'],
|
|
|
|
|
|
|
|
// commentVersion, content, contentSource, isDeleted
|
|
|
|
1,
|
|
|
|
$row['content'],
|
|
|
|
$content_source,
|
|
|
|
0,
|
|
|
|
|
|
|
|
// dateCreated, dateModified, revisionPHID, changesetID, legacyCommentID
|
|
|
|
$row['dateCreated'],
|
|
|
|
$row['dateModified'],
|
|
|
|
$revision_phid,
|
|
|
|
null,
|
|
|
|
$row['id']);
|
|
|
|
}
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Done.')."\n";
|