Commit 1efc91f9 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Updated migration tool to handle the multiple aliases to same account scenario

parent 01f2c7c0
Pipeline #6911 passed with stage
in 18 seconds
......@@ -77,20 +77,8 @@ while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$account->creation_time = $date_last_update;
$account->expire_time = null;
if ($account->create()) {
$account_created_count += 1;
$pwd = new Password($db);
$pwd->account_id = $account->id;
$pwd->algorithm = 'MD5';
$pwd->password = $password;
if (!$pwd->create()) {
Logger::getInstance()->error("Failed to create password !");
} else {
$password_created_count += 1;
}
if ($account->getOne()) {
// If an account as multiple aliases we will go here
if (!empty($alias)) {
$al = new Alias($db);
$al->account_id = $account->id;
......@@ -104,7 +92,35 @@ while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
}
}
} else {
Logger::getInstance()->error("Failed to create account !");
if ($account->create()) {
$account_created_count += 1;
$pwd = new Password($db);
$pwd->account_id = $account->id;
$pwd->algorithm = 'MD5';
$pwd->password = $password;
if (!$pwd->create()) {
Logger::getInstance()->error("Failed to create password !");
} else {
$password_created_count += 1;
}
if (!empty($alias)) {
$al = new Alias($db);
$al->account_id = $account->id;
$al->alias = $alias;
$al->domain = $account->domain;
if (!$al->create()) {
Logger::getInstance()->error("Failed to create alias !");
} else {
$alias_created_count += 1;
}
}
} else {
Logger::getInstance()->error("Failed to create account !");
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment