@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$qtable = new PonderQuestionTransaction();
4$atable = new PonderAnswerTransaction();
5
6$conn_w = $qtable->establishConnection('w');
7$conn_w->openTransaction();
8
9echo pht('Migrating Ponder comments to %s...', 'ApplicationTransactions')."\n";
10
11$rows = new LiskRawMigrationIterator($conn_w, 'ponder_comment');
12foreach ($rows as $row) {
13
14 $id = $row['id'];
15 echo pht('Migrating %d...', $id)."\n";
16
17 $type = phid_get_type($row['targetPHID']);
18 switch ($type) {
19 case PonderQuestionPHIDType::TYPECONST:
20 $table_obj = $qtable;
21 $comment_obj = new PonderQuestionTransactionComment();
22 break;
23 case PonderAnswerPHIDType::TYPECONST:
24 $table_obj = $atable;
25 $comment_obj = new PonderAnswerTransactionComment();
26 break;
27 }
28
29 $comment_phid = PhabricatorPHID::generateNewPHID(
30 PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST,
31 $type);
32
33 $xaction_phid = PhabricatorPHID::generateNewPHID(
34 PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST,
35 $type);
36
37 queryfx(
38 $conn_w,
39 'INSERT INTO %T (phid, transactionPHID, authorPHID, viewPolicy, editPolicy,
40 commentVersion, content, contentSource, isDeleted, dateCreated,
41 dateModified)
42 VALUES (%s, %s, %s, %s, %s, %d, %s, %s, %d, %d, %d)',
43 $comment_obj->getTableName(),
44 $comment_phid,
45 $xaction_phid,
46 $row['authorPHID'],
47 'public',
48 $row['authorPHID'],
49 1,
50 $row['content'],
51 PhabricatorContentSource::newForSource(
52 PhabricatorOldWorldContentSource::SOURCECONST)->serialize(),
53 0,
54 $row['dateCreated'],
55 $row['dateModified']);
56
57 queryfx(
58 $conn_w,
59 'INSERT INTO %T (phid, authorPHID, objectPHID, viewPolicy, editPolicy,
60 commentPHID, commentVersion, transactionType, oldValue, newValue,
61 contentSource, metadata, dateCreated, dateModified)
62 VALUES (%s, %s, %s, %s, %s, %s, %d, %s, %ns, %ns, %s, %s, %d, %d)',
63 $table_obj->getTableName(),
64 $xaction_phid,
65 $row['authorPHID'],
66 $row['targetPHID'],
67 'public',
68 $row['authorPHID'],
69 $comment_phid,
70 1,
71 PhabricatorTransactions::TYPE_COMMENT,
72 'null',
73 'null',
74 PhabricatorContentSource::newForSource(
75 PhabricatorOldWorldContentSource::SOURCECONST)->serialize(),
76 '[]',
77 $row['dateCreated'],
78 $row['dateModified']);
79
80}
81
82$conn_w->saveTransaction();
83
84echo pht('Done.')."\n";