Possible fix for #667

This commit is contained in:
James Cole 2017-06-08 10:54:15 +02:00
parent b48de98865
commit a2145f6b49
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E

View File

@ -316,6 +316,7 @@ class UpgradeDatabase extends Command
$notification = '%s #%d uses %s but should use %s. It has been updated. Please verify this in Firefly III.';
$transfer = 'Transfer #%d has been updated to use the correct currencies. Please verify this in Firefly III.';
$driver = DB::connection()->getDriverName();
$pgsql = ['pgsql', 'postgresql'];
foreach ($types as $type => $operator) {
$query = TransactionJournal
@ -328,10 +329,10 @@ class UpgradeDatabase extends Command
->leftJoin('account_meta', 'account_meta.account_id', '=', 'accounts.id')
->where('transaction_types.type', $type)
->where('account_meta.name', 'currency_id');
if ($driver === 'postgresql') {
if (in_array($driver, $pgsql)) {
$query->where('transaction_journals.transaction_currency_id', '!=', DB::raw('cast(account_meta.data as int)'));
}
if ($driver !== 'postgresql') {
if (!in_array($driver, $pgsql)) {
$query->where('transaction_journals.transaction_currency_id', '!=', DB::raw('account_meta.data'));
}