mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 02:32:42 +01:00
601aaa5a86
Summary: Ref T10537. For Nuance, I want to introduce new sources (like "GitHub" or "GitHub via Nuance" or something) but this needs to modularize eventually. Split ContentSource apart so applications can add new content sources. Test Plan: This change has huge surface area, so I'll hold it until post-release. I think it's fairly safe (and if it does break anything, the breaks should be fatals, not anything subtle or difficult to fix), there's just no reason not to hold it for a few hours. - Viewed new module page. - Grepped for all removed functions/constants. - Viewed some transactions. - Hovered over timestamps to get content source details. - Added a comment via Conduit. - Added a comment via web. - Ran `bin/storage upgrade --namespace XXXXX --no-quickstart -f` to re-run all historic migrations. - Generated some objects with `bin/lipsum`. - Ran a bulk job on some tasks. - Ran unit tests. {F1190182} Reviewers: chad Reviewed By: chad Maniphest Tasks: T10537 Differential Revision: https://secure.phabricator.com/D15521
70 lines
2 KiB
PHP
70 lines
2 KiB
PHP
<?php
|
|
|
|
$conn_w = id(new DifferentialRevision())->establishConnection('w');
|
|
$rows = new LiskRawMigrationIterator($conn_w, 'differential_comment');
|
|
|
|
$content_source = PhabricatorContentSource::newForSource(
|
|
PhabricatorOldWorldContentSource::SOURCECONST)->serialize();
|
|
|
|
echo pht('Migrating Differential comment text to modern storage...')."\n";
|
|
foreach ($rows as $row) {
|
|
$id = $row['id'];
|
|
echo pht('Migrating Differential comment %d...', $id)."\n";
|
|
if (!strlen($row['content'])) {
|
|
echo pht('Comment has no text, continuing.')."\n";
|
|
continue;
|
|
}
|
|
|
|
$revision = id(new DifferentialRevision())->load($row['revisionID']);
|
|
if (!$revision) {
|
|
echo pht('Comment has no valid revision, continuing.')."\n";
|
|
continue;
|
|
}
|
|
|
|
$revision_phid = $revision->getPHID();
|
|
|
|
$dst_table = 'differential_inline_comment';
|
|
|
|
$xaction_phid = PhabricatorPHID::generateNewPHID(
|
|
PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST,
|
|
DifferentialRevisionPHIDType::TYPECONST);
|
|
|
|
$comment_phid = PhabricatorPHID::generateNewPHID(
|
|
PhabricatorPHIDConstants::PHID_TYPE_XCMT,
|
|
DifferentialRevisionPHIDType::TYPECONST);
|
|
|
|
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']);
|
|
}
|
|
|
|
echo pht('Done.')."\n";
|