Changeset View
Changeset View
Standalone View
Standalone View
resources/sql/patches/emailtableport.php
| <?php | <?php | ||||
| echo "Migrating user emails...\n"; | echo pht('Migrating user emails...')."\n"; | ||||
| $table = new PhabricatorUser(); | $table = new PhabricatorUser(); | ||||
| $table->openTransaction(); | $table->openTransaction(); | ||||
| $conn = $table->establishConnection('w'); | $conn = $table->establishConnection('w'); | ||||
| $emails = queryfx_all( | $emails = queryfx_all( | ||||
| $conn, | $conn, | ||||
| 'SELECT phid, email FROM %T LOCK IN SHARE MODE', | 'SELECT phid, email FROM %T LOCK IN SHARE MODE', | ||||
| $table->getTableName()); | $table->getTableName()); | ||||
| $emails = ipull($emails, 'email', 'phid'); | $emails = ipull($emails, 'email', 'phid'); | ||||
| $etable = new PhabricatorUserEmail(); | $etable = new PhabricatorUserEmail(); | ||||
| foreach ($emails as $phid => $email) { | foreach ($emails as $phid => $email) { | ||||
| // NOTE: Grandfather all existing email in as primary / verified. We generate | // NOTE: Grandfather all existing email in as primary / verified. We generate | ||||
| // verification codes because they are used for password resets, etc. | // verification codes because they are used for password resets, etc. | ||||
| echo "Migrating '{$phid}'...\n"; | echo pht("Migrating '%s'...", $phid)."\n"; | ||||
| queryfx( | queryfx( | ||||
| $conn, | $conn, | ||||
| 'INSERT INTO %T (userPHID, address, verificationCode, isVerified, isPrimary) | 'INSERT INTO %T (userPHID, address, verificationCode, isVerified, isPrimary) | ||||
| VALUES (%s, %s, %s, 1, 1)', | VALUES (%s, %s, %s, 1, 1)', | ||||
| $etable->getTableName(), | $etable->getTableName(), | ||||
| $phid, | $phid, | ||||
| $email, | $email, | ||||
| Filesystem::readRandomCharacters(24)); | Filesystem::readRandomCharacters(24)); | ||||
| } | } | ||||
| $table->saveTransaction(); | $table->saveTransaction(); | ||||
| echo "Done.\n"; | echo pht('Done.')."\n"; | ||||