Multi-db support

This commit is contained in:
Hillel Coren 2017-05-03 21:00:42 +03:00
parent 782ae969a4
commit 7b797da220
2 changed files with 5 additions and 4 deletions

View File

@ -54,7 +54,8 @@ class InitLookup extends Command
config(['database.default' => DB_NINJA_LOOKUP]); 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')) { if ($this->option('truncate')) {
$this->truncateTables(); $this->truncateTables();
@ -72,6 +73,7 @@ class InitLookup extends Command
} }
$this->info($this->log); $this->info($this->log);
$this->info('Valid: ' . ($this->isValid ? RESULT_SUCCESS : RESULT_FAILURE));
if ($this->option('validate')) { if ($this->option('validate')) {
if ($errorEmail = env('ERROR_EMAIL')) { if ($errorEmail = env('ERROR_EMAIL')) {
@ -105,7 +107,6 @@ class InitLookup extends Command
config(['database.default' => DB_NINJA_LOOKUP]); config(['database.default' => DB_NINJA_LOOKUP]);
foreach ($data as $companyId => $company) { foreach ($data as $companyId => $company) {
$this->logMessage('Company Id: ' . $companyId);
if ($this->option('validate')) { if ($this->option('validate')) {
$lookupCompany = LookupCompany::whereDbServerId($dbServerId)->whereCompanyId($companyId)->first(); $lookupCompany = LookupCompany::whereDbServerId($dbServerId)->whereCompanyId($companyId)->first();

View File

@ -34,13 +34,13 @@ class PruneData extends Command
$sql = 'select c.id $sql = 'select c.id
from companies c from companies c
left join accounts a on a.company_id = c.id 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 tasks t on t.account_id = a.id
left join expenses e on e.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 left join users u on u.account_id = a.id and u.registered = 1
where c.created_at < DATE_SUB(now(), INTERVAL 6 MONTH) where c.created_at < DATE_SUB(now(), INTERVAL 6 MONTH)
group by c.id group by c.id
having count(c.id) = 0 having count(cl.id) = 0
and count(t.id) = 0 and count(t.id) = 0
and count(e.id) = 0 and count(e.id) = 0
and count(u.id) = 0'; and count(u.id) = 0';