Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/patches/20130403.conpherencecachemig.php
| <?php | <?php | ||||
| echo "Migrating data from conpherence transactions to conpherence 'cache'...\n"; | echo pht( | ||||
| "Migrating data from conpherence transactions to conpherence 'cache'...\n"); | |||||
| $table = new ConpherenceThread(); | $table = new ConpherenceThread(); | ||||
| $table->openTransaction(); | $table->openTransaction(); | ||||
| $conn_w = $table->establishConnection('w'); | $conn_w = $table->establishConnection('w'); | ||||
| $participant_table = new ConpherenceParticipant(); | $participant_table = new ConpherenceParticipant(); | ||||
| $conpherences = new LiskMigrationIterator($table); | $conpherences = new LiskMigrationIterator($table); | ||||
| foreach ($conpherences as $conpherence) { | foreach ($conpherences as $conpherence) { | ||||
| echo 'Migrating conpherence #'.$conpherence->getID()."\n"; | echo pht('Migrating conpherence #%d', $conpherence->getID())."\n"; | ||||
| $participants = id(new ConpherenceParticipant()) | $participants = id(new ConpherenceParticipant()) | ||||
| ->loadAllWhere('conpherencePHID = %s', $conpherence->getPHID()); | ->loadAllWhere('conpherencePHID = %s', $conpherence->getPHID()); | ||||
| $transactions = id(new ConpherenceTransaction()) | $transactions = id(new ConpherenceTransaction()) | ||||
| ->loadAllWhere('objectPHID = %s', $conpherence->getPHID()); | ->loadAllWhere('objectPHID = %s', $conpherence->getPHID()); | ||||
| $participation_hash = mgroup($participants, 'getBehindTransactionPHID'); | $participation_hash = mgroup($participants, 'getBehindTransactionPHID'); | ||||
| Show All 34 Lines | queryfx( | ||||
| 'WHERE phid = %s', | 'WHERE phid = %s', | ||||
| $table->getTableName(), | $table->getTableName(), | ||||
| json_encode($participants_to_cache), | json_encode($participants_to_cache), | ||||
| $message_count, | $message_count, | ||||
| $conpherence->getPHID()); | $conpherence->getPHID()); | ||||
| } | } | ||||
| $table->saveTransaction(); | $table->saveTransaction(); | ||||
| echo "\nDone.\n"; | echo "\n".pht('Done.')."\n"; | ||||