1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +01:00
phorge-phorge/resources/sql/patches/legalpad-mailkey-populate.php

26 lines
575 B
PHP
Raw Normal View History

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