protected function run3($stage)
{
$this->console->out('Updating `scaling_metrics`.`account_id`; Deleting broken records.');
$this->db->Execute("UPDATE `scaling_metrics` SET `account_id` = NULL WHERE `account_id` = 0");
$affected = $this->db->Affected_Rows();
$this->console->out("Updated {$affected} metrics.");
$this->db->Execute("\n DELETE FROM scaling_metrics\n WHERE account_id > 0 AND NOT EXISTS (\n SELECT 1 FROM clients\n WHERE clients.id = scaling_metrics.account_id\n )\n ");
$affected = $this->db->Affected_Rows();
$this->console->out("Deleted {$affected} outdated metrics.");
}