2013-07-15 13:20:10 +02:00
|
|
|
<?php
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Moving Slowvote comments to transactions...')."\n";
|
2013-07-15 13:20:10 +02:00
|
|
|
|
|
|
|
$viewer = PhabricatorUser::getOmnipotentUser();
|
|
|
|
|
|
|
|
$table_xaction = new PhabricatorSlowvoteTransaction();
|
|
|
|
$table_comment = new PhabricatorSlowvoteTransactionComment();
|
|
|
|
$conn_w = $table_xaction->establishConnection('w');
|
|
|
|
|
|
|
|
$comments = new LiskRawMigrationIterator($conn_w, 'slowvote_comment');
|
|
|
|
|
|
|
|
$conn_w->openTransaction();
|
|
|
|
|
|
|
|
foreach ($comments as $comment) {
|
|
|
|
$id = $comment['id'];
|
|
|
|
$poll_id = $comment['pollID'];
|
|
|
|
$author_phid = $comment['authorPHID'];
|
|
|
|
$text = $comment['commentText'];
|
|
|
|
$date_created = $comment['dateCreated'];
|
|
|
|
$date_modified = $comment['dateModified'];
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Migrating comment %d.', $id)."\n";
|
2013-07-15 13:20:10 +02:00
|
|
|
|
|
|
|
$poll = id(new PhabricatorSlowvoteQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withIDs(array($poll_id))
|
|
|
|
->executeOne();
|
|
|
|
if (!$poll) {
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('No poll.')."\n";
|
2013-07-15 13:20:10 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$user = id(new PhabricatorPeopleQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withPHIDs(array($author_phid))
|
|
|
|
->executeOne();
|
|
|
|
if (!$user) {
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('No user.')."\n";
|
2013-07-15 13:20:10 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$comment_phid = PhabricatorPHID::generateNewPHID(
|
|
|
|
PhabricatorPHIDConstants::PHID_TYPE_XCMT);
|
|
|
|
$xaction_phid = PhabricatorPHID::generateNewPHID(
|
2014-07-24 00:05:46 +02:00
|
|
|
PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST,
|
|
|
|
PhabricatorSlowvotePollPHIDType::TYPECONST);
|
2013-07-15 13:20:10 +02:00
|
|
|
|
2016-03-25 13:56:16 +01:00
|
|
|
$content_source = PhabricatorContentSource::newForSource(
|
|
|
|
PhabricatorOldWorldContentSource::SOURCECONST)->serialize();
|
2013-07-15 13:20:10 +02:00
|
|
|
|
|
|
|
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)',
|
|
|
|
$table_comment->getTableName(),
|
|
|
|
$comment_phid,
|
|
|
|
$xaction_phid,
|
|
|
|
$user->getPHID(),
|
|
|
|
PhabricatorPolicies::POLICY_PUBLIC,
|
|
|
|
$user->getPHID(),
|
|
|
|
1,
|
|
|
|
$text,
|
|
|
|
$source,
|
|
|
|
0,
|
|
|
|
$date_created,
|
|
|
|
$date_modified);
|
|
|
|
|
|
|
|
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, %s, %s,
|
|
|
|
%s, %s, %d, %d)',
|
|
|
|
$table_xaction->getTableName(),
|
|
|
|
$xaction_phid,
|
|
|
|
$user->getPHID(),
|
|
|
|
$poll->getPHID(),
|
|
|
|
PhabricatorPolicies::POLICY_PUBLIC,
|
|
|
|
$user->getPHID(),
|
|
|
|
$comment_phid,
|
|
|
|
1,
|
|
|
|
PhabricatorTransactions::TYPE_COMMENT,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
$source,
|
|
|
|
'{}',
|
|
|
|
$date_created,
|
|
|
|
$date_modified);
|
|
|
|
}
|
|
|
|
|
|
|
|
$conn_w->saveTransaction();
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Done.')."\n";
|