[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/resources/sql/patches/ -> emailtableport.php (source)

   1  <?php
   2  
   3  echo "Migrating user emails...\n";
   4  
   5  $table  = new PhabricatorUser();
   6  $table->openTransaction();
   7  $conn   = $table->establishConnection('w');
   8  
   9  $emails = queryfx_all(
  10    $conn,
  11    'SELECT phid, email FROM %T LOCK IN SHARE MODE',
  12    $table->getTableName());
  13  $emails = ipull($emails, 'email', 'phid');
  14  
  15  $etable = new PhabricatorUserEmail();
  16  
  17  foreach ($emails as $phid => $email) {
  18  
  19    // NOTE: Grandfather all existing email in as primary / verified. We generate
  20    // verification codes because they are used for password resets, etc.
  21  
  22    echo "Migrating '{$phid}'...\n";
  23    queryfx(
  24      $conn,
  25      'INSERT INTO %T (userPHID, address, verificationCode, isVerified, isPrimary)
  26        VALUES (%s, %s, %s, 1, 1)',
  27      $etable->getTableName(),
  28      $phid,
  29      $email,
  30      Filesystem::readRandomCharacters(24));
  31  }
  32  
  33  $table->saveTransaction();
  34  echo "Done.\n";


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1