@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3$revision_table = new DifferentialRevision();
4$conn_w = $revision_table->establishConnection('w');
5$conn_w->openTransaction();
6
7$src_table = 'differential_inlinecomment';
8$dst_table = 'differential_transaction_comment';
9
10echo pht('Migrating Differential inline comments to new format...')."\n";
11
12$content_source = PhabricatorContentSource::newForSource(
13 PhabricatorOldWorldContentSource::SOURCECONST)->serialize();
14
15$rows = new LiskRawMigrationIterator($conn_w, $src_table);
16foreach ($rows as $row) {
17 $id = $row['id'];
18
19 $revision_id = $row['revisionID'];
20
21 echo pht('Migrating inline #%d (%s)...', $id, "D{$revision_id}")."\n";
22
23 $revision_row = queryfx_one(
24 $conn_w,
25 'SELECT phid FROM %T WHERE id = %d',
26 $revision_table->getTableName(),
27 $revision_id);
28 if (!$revision_row) {
29 continue;
30 }
31
32 $revision_phid = $revision_row['phid'];
33
34 if ($row['commentID']) {
35 $xaction_phid = PhabricatorPHID::generateNewPHID(
36 PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST,
37 DifferentialRevisionPHIDType::TYPECONST);
38 } else {
39 $xaction_phid = null;
40 }
41
42 $comment_phid = PhabricatorPHID::generateNewPHID(
43 PhabricatorPHIDConstants::PHID_TYPE_XCMT,
44 DifferentialRevisionPHIDType::TYPECONST);
45
46 queryfx(
47 $conn_w,
48 'INSERT IGNORE INTO %T
49 (id, phid, transactionPHID, authorPHID, viewPolicy, editPolicy,
50 commentVersion, content, contentSource, isDeleted,
51 dateCreated, dateModified, revisionPHID, changesetID,
52 isNewFile, lineNumber, lineLength, hasReplies, legacyCommentID)
53 VALUES (%d, %s, %ns, %s, %s, %s,
54 %d, %s, %s, %d,
55 %d, %d, %s, %nd,
56 %d, %d, %d, %d, %nd)',
57 $dst_table,
58
59 // id, phid, transactionPHID, authorPHID, viewPolicy, editPolicy
60 $row['id'],
61 $comment_phid,
62 $xaction_phid,
63 $row['authorPHID'],
64 'public',
65 $row['authorPHID'],
66
67 // commentVersion, content, contentSource, isDeleted
68 1,
69 $row['content'],
70 $content_source,
71 0,
72
73 // dateCreated, dateModified, revisionPHID, changesetID
74 $row['dateCreated'],
75 $row['dateModified'],
76 $revision_phid,
77 $row['changesetID'],
78
79 // isNewFile, lineNumber, lineLength, hasReplies, legacyCommentID
80 $row['isNewFile'],
81 $row['lineNumber'],
82 $row['lineLength'],
83 0,
84 $row['commentID']);
85
86}
87
88$conn_w->saveTransaction();
89echo pht('Done.')."\n";