Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/patches/20121209.xmacromigrate.php
| <?php | <?php | ||||
| echo "Giving image macros PHIDs"; | echo 'Giving image macros PHIDs'; | ||||
| $table = new PhabricatorFileImageMacro(); | $table = new PhabricatorFileImageMacro(); | ||||
| $table->openTransaction(); | $table->openTransaction(); | ||||
| foreach (new LiskMigrationIterator($table) as $macro) { | foreach (new LiskMigrationIterator($table) as $macro) { | ||||
| if ($macro->getPHID()) { | if ($macro->getPHID()) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| echo "."; | echo '.'; | ||||
| queryfx( | queryfx( | ||||
| $macro->establishConnection('w'), | $macro->establishConnection('w'), | ||||
| 'UPDATE %T SET phid = %s WHERE id = %d', | 'UPDATE %T SET phid = %s WHERE id = %d', | ||||
| $macro->getTableName(), | $macro->getTableName(), | ||||
| $macro->generatePHID(), | $macro->generatePHID(), | ||||
| $macro->getID()); | $macro->getID()); | ||||
| } | } | ||||
| $table->saveTransaction(); | $table->saveTransaction(); | ||||
| echo "\nDone.\n"; | echo "\nDone.\n"; | ||||