mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
This commit is contained in:
parent
25f99b23b2
commit
f38e510526
@ -99,10 +99,8 @@ class PiggyBankTransformer extends AbstractTransformer
|
|||||||
'id' => (string) $piggyBank->id,
|
'id' => (string) $piggyBank->id,
|
||||||
'created_at' => $piggyBank->created_at->toAtomString(),
|
'created_at' => $piggyBank->created_at->toAtomString(),
|
||||||
'updated_at' => $piggyBank->updated_at->toAtomString(),
|
'updated_at' => $piggyBank->updated_at->toAtomString(),
|
||||||
'accounts' => $this->renderAccounts($piggyBank),
|
|
||||||
// 'account_id' => (string)$piggyBank->account_id,
|
|
||||||
// 'account_name' => $piggyBank->account->name,
|
|
||||||
'name' => $piggyBank->name,
|
'name' => $piggyBank->name,
|
||||||
|
'accounts' => $this->renderAccounts($piggyBank),
|
||||||
'currency_id' => (string) $currency->id,
|
'currency_id' => (string) $currency->id,
|
||||||
'currency_code' => $currency->code,
|
'currency_code' => $currency->code,
|
||||||
'currency_symbol' => $currency->symbol,
|
'currency_symbol' => $currency->symbol,
|
||||||
@ -137,6 +135,7 @@ class PiggyBankTransformer extends AbstractTransformer
|
|||||||
'id' => $account->id,
|
'id' => $account->id,
|
||||||
'name' => $account->name,
|
'name' => $account->name,
|
||||||
'current_amount' => (string) $account->pivot->current_amount,
|
'current_amount' => (string) $account->pivot->current_amount,
|
||||||
|
'native_current_amount'=> (string) $account->pivot->native_current_amount,
|
||||||
// TODO add balance, add left to save.
|
// TODO add balance, add left to save.
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class () extends Migration {
|
return new class () extends Migration {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
*/
|
*/
|
||||||
@ -37,8 +38,9 @@ return new class () extends Migration {
|
|||||||
// make account_id nullable and the relation also nullable.
|
// make account_id nullable and the relation also nullable.
|
||||||
try {
|
try {
|
||||||
Schema::table('piggy_banks', static function (Blueprint $table): void {
|
Schema::table('piggy_banks', static function (Blueprint $table): void {
|
||||||
// 1. drop index
|
if (self::hasForeign('piggy_banks', 'piggy_banks_account_id_foreign')) {
|
||||||
$table->dropForeign('piggy_banks_account_id_foreign');
|
$table->dropForeign('piggy_banks_account_id_foreign');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (RuntimeException $e) {
|
} catch (RuntimeException $e) {
|
||||||
Log::error('Could not drop foreign key "piggy_banks_account_id_foreign". Probably not an issue.');
|
Log::error('Could not drop foreign key "piggy_banks_account_id_foreign". Probably not an issue.');
|
||||||
@ -105,7 +107,9 @@ return new class () extends Migration {
|
|||||||
$table->renameColumn('target_date_tz', 'targetdate_tz');
|
$table->renameColumn('target_date_tz', 'targetdate_tz');
|
||||||
|
|
||||||
// 3. drop currency again + index
|
// 3. drop currency again + index
|
||||||
|
if (self::hasForeign('piggy_banks', 'unique_currency')) {
|
||||||
$table->dropForeign('unique_currency');
|
$table->dropForeign('unique_currency');
|
||||||
|
}
|
||||||
$table->dropColumn('transaction_currency_id');
|
$table->dropColumn('transaction_currency_id');
|
||||||
|
|
||||||
// 2. make column non-nullable.
|
// 2. make column non-nullable.
|
||||||
@ -127,4 +131,15 @@ return new class () extends Migration {
|
|||||||
|
|
||||||
Schema::dropIfExists('account_piggy_bank');
|
Schema::dropIfExists('account_piggy_bank');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static function hasForeign(string $table, string $column) {
|
||||||
|
|
||||||
|
$foreignKeysDefinitions = Schema::getForeignKeys($table);
|
||||||
|
foreach($foreignKeysDefinitions as $foreignKeyDefinition) {
|
||||||
|
if($foreignKeyDefinition['name'] === $column) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user