Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/patches/20130529.macroauthormig.php
| <?php | <?php | ||||
| echo "Migrating macro authors...\n"; | echo pht('Migrating macro authors...')."\n"; | ||||
| foreach (new LiskMigrationIterator(new PhabricatorFileImageMacro()) as $macro) { | foreach (new LiskMigrationIterator(new PhabricatorFileImageMacro()) as $macro) { | ||||
| echo "Macro #".$macro->getID()."\n"; | echo pht('Macro #%d', $macro->getID())."\n"; | ||||
| if ($macro->getAuthorPHID()) { | if ($macro->getAuthorPHID()) { | ||||
| // Already have an author; skip it. | // Already have an author; skip it. | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (!$macro->getFilePHID()) { | if (!$macro->getFilePHID()) { | ||||
| // No valid file; skip it. | // No valid file; skip it. | ||||
| Show All 17 Lines | foreach (new LiskMigrationIterator(new PhabricatorFileImageMacro()) as $macro) { | ||||
| queryfx( | queryfx( | ||||
| $macro->establishConnection('w'), | $macro->establishConnection('w'), | ||||
| 'UPDATE %T SET authorPHID = %s WHERE id = %d', | 'UPDATE %T SET authorPHID = %s WHERE id = %d', | ||||
| $macro->getTableName(), | $macro->getTableName(), | ||||
| $file->getAuthorPHID(), | $file->getAuthorPHID(), | ||||
| $macro->getID()); | $macro->getID()); | ||||
| } | } | ||||
| echo "Done.\n"; | echo pht('Done.')."\n"; | ||||