Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/patches/legalpad-mailkey-populate.php
| <?php | <?php | ||||
| echo "Populating Legalpad Documents with mail keys...\n"; | echo pht('Populating Legalpad Documents with mail keys...')."\n"; | ||||
| $table = new LegalpadDocument(); | $table = new LegalpadDocument(); | ||||
| $table->openTransaction(); | $table->openTransaction(); | ||||
| foreach (new LiskMigrationIterator($table) as $document) { | foreach (new LiskMigrationIterator($table) as $document) { | ||||
| $id = $document->getID(); | $id = $document->getID(); | ||||
| echo "Document {$id}: "; | echo pht('Document %s: ', $id); | ||||
| if (!$document->getMailKey()) { | if (!$document->getMailKey()) { | ||||
| queryfx( | queryfx( | ||||
| $document->establishConnection('w'), | $document->establishConnection('w'), | ||||
| 'UPDATE %T SET mailKey = %s WHERE id = %d', | 'UPDATE %T SET mailKey = %s WHERE id = %d', | ||||
| $document->getTableName(), | $document->getTableName(), | ||||
| Filesystem::readRandomCharacters(20), | Filesystem::readRandomCharacters(20), | ||||
| $id); | $id); | ||||
| echo "Generated Key\n"; | echo pht('Generated Key')."\n"; | ||||
| } else { | } else { | ||||
| echo "-\n"; | echo "-\n"; | ||||
| } | } | ||||
| } | } | ||||
| $table->saveTransaction(); | $table->saveTransaction(); | ||||
| echo "Done.\n"; | echo pht('Done.')."\n"; | ||||