2013-07-29 01:55:13 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
$qtable = new PonderQuestionTransaction();
|
|
|
|
$atable = new PonderAnswerTransaction();
|
|
|
|
|
|
|
|
$conn_w = $qtable->establishConnection('w');
|
|
|
|
$conn_w->openTransaction();
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Migrating Ponder comments to %s...', 'ApplicationTransactions')."\n";
|
2013-07-29 01:55:13 +02:00
|
|
|
|
|
|
|
$rows = new LiskRawMigrationIterator($conn_w, 'ponder_comment');
|
|
|
|
foreach ($rows as $row) {
|
|
|
|
|
|
|
|
$id = $row['id'];
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Migrating %d...', $id)."\n";
|
2013-07-29 01:55:13 +02:00
|
|
|
|
|
|
|
$type = phid_get_type($row['targetPHID']);
|
|
|
|
switch ($type) {
|
2014-07-24 00:05:46 +02:00
|
|
|
case PonderQuestionPHIDType::TYPECONST:
|
2013-07-29 01:55:13 +02:00
|
|
|
$table_obj = $qtable;
|
|
|
|
$comment_obj = new PonderQuestionTransactionComment();
|
|
|
|
break;
|
2014-07-24 00:05:46 +02:00
|
|
|
case PonderAnswerPHIDType::TYPECONST:
|
2013-07-29 01:55:13 +02:00
|
|
|
$table_obj = $atable;
|
|
|
|
$comment_obj = new PonderAnswerTransactionComment();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$comment_phid = PhabricatorPHID::generateNewPHID(
|
2014-07-24 00:05:46 +02:00
|
|
|
PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST,
|
2013-07-29 01:55:13 +02:00
|
|
|
$type);
|
|
|
|
|
|
|
|
$xaction_phid = PhabricatorPHID::generateNewPHID(
|
2014-07-24 00:05:46 +02:00
|
|
|
PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST,
|
2013-07-29 01:55:13 +02:00
|
|
|
$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(
|
2016-03-25 13:56:16 +01:00
|
|
|
PhabricatorOldWorldContentSource::SOURCECONST)->serialize(),
|
2013-07-29 01:55:13 +02:00
|
|
|
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(
|
2016-03-25 13:56:16 +01:00
|
|
|
PhabricatorOldWorldContentSource::SOURCECONST)->serialize(),
|
2013-07-29 01:55:13 +02:00
|
|
|
'[]',
|
|
|
|
$row['dateCreated'],
|
|
|
|
$row['dateModified']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$conn_w->saveTransaction();
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Done.')."\n";
|