|
1 | 1 | <?php
|
2 | 2 |
|
3 |
| -echo "Migrating Releeph requests events to transactions...\n"; |
| 3 | +// Previously, this migrated ReleephRequestEvents into ApplicationTransactions. |
| 4 | +// Only Facebook ever generated meaningful ReleephRequestEvent data, and has |
| 5 | +// already migrated, so this was cleaned up when ReleephRequestEvent was |
| 6 | +// removed. |
4 | 7 |
|
5 |
| -$table = new ReleephRequest(); |
6 |
| -$table->openTransaction(); |
7 |
| -$table->beginReadLocking(); |
8 |
| - |
9 |
| -foreach (new LiskMigrationIterator($table) as $rq) { |
10 |
| - printf("RQ%d:", $rq->getID()); |
11 |
| - |
12 |
| - $intents_cursor = array(); |
13 |
| - $last_pick_status = null; |
14 |
| - $last_commit_id = null; |
15 |
| - |
16 |
| - foreach ($rq->loadEvents() as $event) { |
17 |
| - $author = $event->getActorPHID(); |
18 |
| - $details = $event->getDetails(); |
19 |
| - |
20 |
| - $content_source = PhabricatorContentSource::newForSource( |
21 |
| - PhabricatorContentSource::SOURCE_UNKNOWN, |
22 |
| - array('ReleephRequestEventID' => $event->getID())); |
23 |
| - |
24 |
| - $xaction = id(new ReleephRequestTransaction()) |
25 |
| - ->setObjectPHID($rq->getPHID()) |
26 |
| - ->setAuthorPHID($author) |
27 |
| - ->setContentSource($content_source) |
28 |
| - ->setDateCreated($event->getDateCreated()) |
29 |
| - ->setDateModified($event->getDateModified()) |
30 |
| - ->setViewPolicy(PhabricatorPolicies::POLICY_PUBLIC) |
31 |
| - ->setEditPolicy($author); |
32 |
| - |
33 |
| - printf(" %s(#%d)", $event->getType(), $event->getID()); |
34 |
| - |
35 |
| - switch ($event->getType()) { |
36 |
| - case ReleephRequestEvent::TYPE_COMMENT: |
37 |
| - $xaction |
38 |
| - ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) |
39 |
| - ->save(); // to generate a PHID |
40 |
| - $comment = id(new ReleephRequestTransactionComment()) |
41 |
| - ->setAuthorPHID($author) |
42 |
| - ->setTransactionPHID($xaction->getPHID()) |
43 |
| - ->setViewPolicy(PhabricatorPolicies::POLICY_PUBLIC) |
44 |
| - ->setEditPolicy($author) |
45 |
| - ->setCommentVersion(1) |
46 |
| - ->setContent($event->getComment()) |
47 |
| - ->setContentSource($content_source) |
48 |
| - ->save(); |
49 |
| - $xaction |
50 |
| - ->setCommentPHID($comment->getPHID()) |
51 |
| - ->setCommentVersion(1); |
52 |
| - break; |
53 |
| - |
54 |
| - case ReleephRequestEvent::TYPE_STATUS: |
55 |
| - // Ignore STATUS events; these are legacy events that we no longer |
56 |
| - // support anyway! |
57 |
| - continue 2; |
58 |
| - |
59 |
| - case ReleephRequestEvent::TYPE_USER_INTENT: |
60 |
| - $old_intent = idx($intents_cursor, $author); |
61 |
| - $new_intent = $event->getDetail('newIntent'); |
62 |
| - $xaction |
63 |
| - ->setTransactionType(ReleephRequestTransaction::TYPE_USER_INTENT) |
64 |
| - ->setMetadataValue('isAuthoritative', $event->getDetail('wasPusher')) |
65 |
| - ->setOldValue($old_intent) |
66 |
| - ->setNewValue($new_intent); |
67 |
| - $intents_cursor[$author] = $new_intent; |
68 |
| - break; |
69 |
| - |
70 |
| - case ReleephRequestEvent::TYPE_PICK_STATUS: |
71 |
| - $new_pick_status = $event->getDetail('newPickStatus'); |
72 |
| - $xaction |
73 |
| - ->setTransactionType(ReleephRequestTransaction::TYPE_PICK_STATUS) |
74 |
| - ->setOldValue($last_pick_status) |
75 |
| - ->setNewValue($new_pick_status); |
76 |
| - $last_pick_status = $new_pick_status; |
77 |
| - break; |
78 |
| - |
79 |
| - case ReleephRequestEvent::TYPE_COMMIT: |
80 |
| - $new_commit_id = $event->getDetail('newCommitIdentifier'); |
81 |
| - $xaction |
82 |
| - ->setTransactionType(ReleephRequestTransaction::TYPE_COMMIT) |
83 |
| - ->setMetadataValue('action', $event->getDetail('action')) |
84 |
| - ->setOldValue($last_commit_id) |
85 |
| - ->setNewValue($new_commit_id); |
86 |
| - $last_commit_id = $new_commit_id; |
87 |
| - break; |
88 |
| - |
89 |
| - case ReleephRequestEvent::TYPE_DISCOVERY: |
90 |
| - $xaction |
91 |
| - ->setTransactionType(ReleephRequestTransaction::TYPE_DISCOVERY) |
92 |
| - ->setNewValue($event->getDetail('newCommitPHID')); |
93 |
| - break; |
94 |
| - |
95 |
| - case ReleephRequestEvent::TYPE_CREATE: |
96 |
| - $xaction |
97 |
| - ->setTransactionType(ReleephRequestTransaction::TYPE_REQUEST) |
98 |
| - ->setOldValue(null) |
99 |
| - ->setNewValue($rq->getRequestCommitPHID()); |
100 |
| - break; |
101 |
| - |
102 |
| - case ReleephRequestEvent::TYPE_MANUAL_ACTION: |
103 |
| - $xaction |
104 |
| - ->setTransactionType( |
105 |
| - ReleephRequestTransaction::TYPE_MANUAL_IN_BRANCH); |
106 |
| - switch ($event->getDetail('action')) { |
107 |
| - case 'pick': |
108 |
| - $xaction->setNewValue(1); |
109 |
| - break; |
110 |
| - |
111 |
| - case 'revert': |
112 |
| - $xaction->setNewValue(0); |
113 |
| - break; |
114 |
| - } |
115 |
| - break; |
116 |
| - |
117 |
| - default: |
118 |
| - throw new Exception(sprintf( |
119 |
| - "Unhandled ReleephRequestEvent type '%s' in RQ%d", |
120 |
| - $event->getType(), |
121 |
| - $rq->getID())); |
122 |
| - } |
123 |
| - |
124 |
| - $xaction->save(); |
125 |
| - } |
126 |
| - echo("\n"); |
127 |
| -} |
128 |
| - |
129 |
| -$table->endReadLocking(); |
130 |
| -$table->saveTransaction(); |
131 |
| -echo "Done.\n"; |
| 8 | +echo "(This migration is obsolete.)\n"; |
0 commit comments