mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 17:22:42 +01:00
3d78c0eff7
Summary: Ref T4896. This is substantially similar to D8196. Migrate the comment text out of the `audit_comment` table and into the `audit_transaction_comment` table. Do double reads on `PhabricatorAuditComment` so the APIs aren't disturbed. The old table is still updated. Test Plan: - Before applying migration, cleared cache and browsed around. Things looked fine, except no comment text. - Applied migration. - Cleared cache, browsed around, saw all my old comments. - Added some new comments. - Spot checked migrated and new rows in database. Reviewers: btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T4896 Differential Revision: https://secure.phabricator.com/D10020
61 lines
1.7 KiB
PHP
61 lines
1.7 KiB
PHP
<?php
|
|
|
|
$conn_w = id(new PhabricatorAuditTransaction())->establishConnection('w');
|
|
$rows = new LiskRawMigrationIterator($conn_w, 'audit_comment');
|
|
|
|
$content_source = PhabricatorContentSource::newForSource(
|
|
PhabricatorContentSource::SOURCE_LEGACY,
|
|
array())->serialize();
|
|
|
|
echo "Migrating Audit comment text to modern storage...\n";
|
|
foreach ($rows as $row) {
|
|
$id = $row['id'];
|
|
echo "Migrating Audit comment {$id}...\n";
|
|
if (!strlen($row['content'])) {
|
|
echo "Comment has no text, continuing.\n";
|
|
continue;
|
|
}
|
|
|
|
$xaction_phid = PhabricatorPHID::generateNewPHID(
|
|
PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST,
|
|
PhabricatorRepositoryCommitPHIDType::TYPECONST);
|
|
|
|
$comment_phid = PhabricatorPHID::generateNewPHID(
|
|
PhabricatorPHIDConstants::PHID_TYPE_XCMT,
|
|
PhabricatorRepositoryCommitPHIDType::TYPECONST);
|
|
|
|
queryfx(
|
|
$conn_w,
|
|
'INSERT IGNORE INTO %T
|
|
(phid, transactionPHID, authorPHID, viewPolicy, editPolicy,
|
|
commentVersion, content, contentSource, isDeleted,
|
|
dateCreated, dateModified, commitPHID, pathID,
|
|
legacyCommentID)
|
|
VALUES (%s, %s, %s, %s, %s,
|
|
%d, %s, %s, %d,
|
|
%d, %d, %s, %nd,
|
|
%d)',
|
|
'audit_transaction_comment',
|
|
|
|
// phid, transactionPHID, authorPHID, viewPolicy, editPolicy
|
|
$comment_phid,
|
|
$xaction_phid,
|
|
$row['actorPHID'],
|
|
'public',
|
|
$row['actorPHID'],
|
|
|
|
// commentVersion, content, contentSource, isDeleted
|
|
1,
|
|
$row['content'],
|
|
$content_source,
|
|
0,
|
|
|
|
// dateCreated, dateModified, commitPHID, pathID, legacyCommentID
|
|
$row['dateCreated'],
|
|
$row['dateModified'],
|
|
$row['targetPHID'],
|
|
null,
|
|
$row['id']);
|
|
}
|
|
|
|
echo "Done.\n";
|