From 1a4b9ddac6b96e752df478f407048b77daac1c11 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 25 Jul 2021 11:41:13 +1000 Subject: [PATCH] Fixes for forced migration --- app/Console/Commands/ForceMigration.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/Console/Commands/ForceMigration.php b/app/Console/Commands/ForceMigration.php index 31e40f5f32c7..d18b52513ab1 100644 --- a/app/Console/Commands/ForceMigration.php +++ b/app/Console/Commands/ForceMigration.php @@ -57,10 +57,16 @@ class ForceMigration extends Command { $data = []; - $company = Company::where('plan', 'free') - ->where('is_migrated', false) - ->with('accounts') - ->first(); + $company = Company::on(DB_NINJA_1) + ->whereNull('plan') + ->orWhereIn('plan', ['','free']) + ->whereHas('accounts', function ($query){ + $query->where('account_key', 'NOT LIKE', substr(NINJA_ACCOUNT_KEY, 0, 30) . '%'); + }) + ->with('accounts') + ->withCount('accounts') + ->having('accounts_count', '>=', 1) + ->first(); $user = $company->accounts->first()->users()->whereNull('public_id')->orWhere('public_id', 0)->first(); $db = DB_NINJA_1; @@ -72,7 +78,6 @@ class ForceMigration extends Command $data['companies'][$key]['id'] = $account->id; - } $this->dispatch(new HostedMigration($user, $data, $db, true));