mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +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
84 lines
2.3 KiB
PHP
84 lines
2.3 KiB
PHP
<?php
|
|
|
|
$qtable = new PonderQuestionTransaction();
|
|
$atable = new PonderAnswerTransaction();
|
|
|
|
$conn_w = $qtable->establishConnection('w');
|
|
$conn_w->openTransaction();
|
|
|
|
echo pht('Migrating Ponder comments to %s...', 'ApplicationTransactions')."\n";
|
|
|
|
$rows = new LiskRawMigrationIterator($conn_w, 'ponder_comment');
|
|
foreach ($rows as $row) {
|
|
|
|
$id = $row['id'];
|
|
echo pht('Migrating %d...', $id)."\n";
|
|
|
|
$type = phid_get_type($row['targetPHID']);
|
|
switch ($type) {
|
|
case PonderQuestionPHIDType::TYPECONST:
|
|
$table_obj = $qtable;
|
|
$comment_obj = new PonderQuestionTransactionComment();
|
|
break;
|
|
case PonderAnswerPHIDType::TYPECONST:
|
|
$table_obj = $atable;
|
|
$comment_obj = new PonderAnswerTransactionComment();
|
|
break;
|
|
}
|
|
|
|
$comment_phid = PhabricatorPHID::generateNewPHID(
|
|
PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST,
|
|
$type);
|
|
|
|
$xaction_phid = PhabricatorPHID::generateNewPHID(
|
|
PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST,
|
|
$type);
|
|
|
|
queryfx(
|
|
$conn_w,
|
|
'INSERT INTO %T (phid, transactionPHID, authorPHID, viewPolicy, editPolicy,
|
|
commentVersion, content, contentSource, isDeleted, dateCreated,
|
|
dateModified)
|
|
VALUES (%s, %s, %s, %s, %s, %d, %s, %s, %d, %d, %d)',
|
|
$comment_obj->getTableName(),
|
|
$comment_phid,
|
|
$xaction_phid,
|
|
$row['authorPHID'],
|
|
'public',
|
|
$row['authorPHID'],
|
|
1,
|
|
$row['content'],
|
|
PhabricatorContentSource::newForSource(
|
|
PhabricatorOldWorldContentSource::SOURCECONST)->serialize(),
|
|
0,
|
|
$row['dateCreated'],
|
|
$row['dateModified']);
|
|
|
|
queryfx(
|
|
$conn_w,
|
|
'INSERT INTO %T (phid, authorPHID, objectPHID, viewPolicy, editPolicy,
|
|
commentPHID, commentVersion, transactionType, oldValue, newValue,
|
|
contentSource, metadata, dateCreated, dateModified)
|
|
VALUES (%s, %s, %s, %s, %s, %s, %d, %s, %ns, %ns, %s, %s, %d, %d)',
|
|
$table_obj->getTableName(),
|
|
$xaction_phid,
|
|
$row['authorPHID'],
|
|
$row['targetPHID'],
|
|
'public',
|
|
$row['authorPHID'],
|
|
$comment_phid,
|
|
1,
|
|
PhabricatorTransactions::TYPE_COMMENT,
|
|
'null',
|
|
'null',
|
|
PhabricatorContentSource::newForSource(
|
|
PhabricatorOldWorldContentSource::SOURCECONST)->serialize(),
|
|
'[]',
|
|
$row['dateCreated'],
|
|
$row['dateModified']);
|
|
|
|
}
|
|
|
|
$conn_w->saveTransaction();
|
|
|
|
echo pht('Done.')."\n";
|