From 7b797da220cca0680e1290b7a075c10996086c63 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 3 May 2017 21:00:42 +0300 Subject: [PATCH] Multi-db support --- app/Console/Commands/InitLookup.php | 5 +++-- app/Console/Commands/PruneData.php | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/InitLookup.php b/app/Console/Commands/InitLookup.php index 2dfa0facd7e4..d639068b035f 100644 --- a/app/Console/Commands/InitLookup.php +++ b/app/Console/Commands/InitLookup.php @@ -54,7 +54,8 @@ class InitLookup extends Command config(['database.default' => DB_NINJA_LOOKUP]); - $dbServer = DbServer::whereName($this->option('database'))->first(); + $database = $this->option('database'); + $dbServer = DbServer::whereName($database)->first(); if ($this->option('truncate')) { $this->truncateTables(); @@ -72,6 +73,7 @@ class InitLookup extends Command } $this->info($this->log); + $this->info('Valid: ' . ($this->isValid ? RESULT_SUCCESS : RESULT_FAILURE)); if ($this->option('validate')) { if ($errorEmail = env('ERROR_EMAIL')) { @@ -105,7 +107,6 @@ class InitLookup extends Command config(['database.default' => DB_NINJA_LOOKUP]); foreach ($data as $companyId => $company) { - $this->logMessage('Company Id: ' . $companyId); if ($this->option('validate')) { $lookupCompany = LookupCompany::whereDbServerId($dbServerId)->whereCompanyId($companyId)->first(); diff --git a/app/Console/Commands/PruneData.php b/app/Console/Commands/PruneData.php index d0b889f5ab68..1d350e1933e1 100644 --- a/app/Console/Commands/PruneData.php +++ b/app/Console/Commands/PruneData.php @@ -34,13 +34,13 @@ class PruneData extends Command $sql = 'select c.id from companies c left join accounts a on a.company_id = c.id - left join clients c on c.account_id = a.id + left join clients cl on cl.account_id = a.id left join tasks t on t.account_id = a.id left join expenses e on e.account_id = a.id left join users u on u.account_id = a.id and u.registered = 1 where c.created_at < DATE_SUB(now(), INTERVAL 6 MONTH) group by c.id - having count(c.id) = 0 + having count(cl.id) = 0 and count(t.id) = 0 and count(e.id) = 0 and count(u.id) = 0';