protected function run2($stage)
{
$hasone = false;
//Selects only those users who do not have any key yet
$rs = $this->db->Execute("\n SELECT u.id FROM `account_users` u\n LEFT JOIN `account_user_apikeys` k ON k.user_id = u.id\n WHERE k.user_id IS NULL\n ");
while ($rec = $rs->FetchRow()) {
if (!$hasone) {
$this->console->out("Initializing API keys for all users who do not have one...");
$hasone = true;
}
try {
$apiKey = new ApiKeyEntity($rec['id']);
$apiKey->save();
} catch (\Exception $e) {
continue;
}
}
}