1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 13:30:55 +01:00
phorge-phorge/resources/sql/patches/20130926.dinline.php
epriestley 601aaa5a86 Modularize content sources
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
2016-03-26 11:59:45 -07:00

89 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 pht('Migrating Differential inline comments to new format...')."\n";
$content_source = PhabricatorContentSource::newForSource(
PhabricatorOldWorldContentSource::SOURCECONST)->serialize();
$rows = new LiskRawMigrationIterator($conn_w, $src_table);
foreach ($rows as $row) {
$id = $row['id'];
$revision_id = $row['revisionID'];
echo pht('Migrating inline #%d (%s)...', $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 pht('Done.')."\n";