Remove hard exit from upgrade routine.

This commit is contained in:
James Cole
2018-04-08 16:26:26 +02:00
parent b561e79a6c
commit 7583698ee5

View File

@@ -77,7 +77,6 @@ class UpgradeDatabase extends Command
*/ */
public function handle() public function handle()
{ {
$this->migrateBillsToRules();
$this->setTransactionIdentifier(); $this->setTransactionIdentifier();
$this->updateAccountCurrencies(); $this->updateAccountCurrencies();
$this->createNewTypes(); $this->createNewTypes();
@@ -87,6 +86,7 @@ class UpgradeDatabase extends Command
$this->line('Done updating currency information..'); $this->line('Done updating currency information..');
$this->migrateNotes(); $this->migrateNotes();
$this->migrateAttachmentData(); $this->migrateAttachmentData();
$this->migrateBillsToRules();
$this->info('Firefly III database is up to date.'); $this->info('Firefly III database is up to date.');
} }
@@ -100,6 +100,9 @@ class UpgradeDatabase extends Command
$ruleGroup = $user->ruleGroups()->where('title', $groupName)->first(); $ruleGroup = $user->ruleGroups()->where('title', $groupName)->first();
$currencyPreference = Preferences::getForUser($user, 'currencyPreference', config('firefly.default_currency', 'EUR')); $currencyPreference = Preferences::getForUser($user, 'currencyPreference', config('firefly.default_currency', 'EUR'));
$currency = TransactionCurrency::where('code', $currencyPreference->data)->first(); $currency = TransactionCurrency::where('code', $currencyPreference->data)->first();
if (null === $currency) {
$currency = app('amount')->getDefaultCurrency();
}
if ($ruleGroup === null) { if ($ruleGroup === null) {
$array = RuleGroup::get(['order'])->pluck('order')->toArray(); $array = RuleGroup::get(['order'])->pluck('order')->toArray();
@@ -190,14 +193,18 @@ class UpgradeDatabase extends Command
); );
$order++; $order++;
//$bill->match = 'MIGRATED_TO_RULES'; $bill->match = 'MIGRATED_TO_RULES';
$bill->save(); $bill->save();
$this->line(sprintf('Updated bill #%d ("%s") so it will use rules.', $bill->id, $bill->name)); $this->line(sprintf('Updated bill #%d ("%s") so it will use rules.', $bill->id, $bill->name));
} }
}
$this->line('Exit'); // give bills a currency when they dont have one.
exit; if (null === $bill->transaction_currency_id) {
$this->line(sprintf('Gave bill #%d ("%s") a currency (%s).', $bill->id, $bill->name, $currency->name));
$bill->transactionCurrency()->associate($currency);
$bill->save();
}
}
} }
} }