mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 13:00:56 +01:00
e10fdbe77e
Summary: Patches often read from slaves (possibly stale data) and use that information to write on master. It causes problems when applying more patches quickly after each other because data created in previous patch may not be replicated yet. Test Plan: $ bin/storage upgrade Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4483
34 lines
847 B
PHP
34 lines
847 B
PHP
<?php
|
|
|
|
echo "Migrating user emails...\n";
|
|
|
|
$table = new PhabricatorUser();
|
|
$table->openTransaction();
|
|
$conn = $table->establishConnection('w');
|
|
|
|
$emails = queryfx_all(
|
|
$conn,
|
|
'SELECT phid, email FROM %T LOCK IN SHARE MODE',
|
|
$table->getTableName());
|
|
$emails = ipull($emails, 'email', 'phid');
|
|
|
|
$etable = new PhabricatorUserEmail();
|
|
|
|
foreach ($emails as $phid => $email) {
|
|
|
|
// NOTE: Grandfather all existing email in as primary / verified. We generate
|
|
// verification codes because they are used for password resets, etc.
|
|
|
|
echo "Migrating '{$phid}'...\n";
|
|
queryfx(
|
|
$conn,
|
|
'INSERT INTO %T (userPHID, address, verificationCode, isVerified, isPrimary)
|
|
VALUES (%s, %s, %s, 1, 1)',
|
|
$etable->getTableName(),
|
|
$phid,
|
|
$email,
|
|
Filesystem::readRandomCharacters(24));
|
|
}
|
|
|
|
$table->saveTransaction();
|
|
echo "Done.\n";
|