mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-28 18:51:55 +00:00
Add native amount column
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
private array $tables = [
|
||||
'accounts' => ['native_virtual_balance'],
|
||||
'account_piggy_bank' => ['native_current_amount'],
|
||||
'auto_budgets' => ['native_amount'],
|
||||
'available_budgets' => ['native_amount'],
|
||||
'bills' => ['native_amount_min', 'native_amount_max'],
|
||||
'budget_limits' => ['native_amount'],
|
||||
'piggy_bank_events' => ['native_amount'],
|
||||
'piggy_banks' => ['native_target_amount'],
|
||||
'transactions' => ['native_amount'],
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
foreach ($this->tables as $table => $fields) {
|
||||
foreach ($fields as $field) {
|
||||
Schema::table($table, static function (Blueprint $table) use ($field): void {
|
||||
// add amount column
|
||||
$table->decimal($field, 32, 12)->nullable();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
foreach ($this->tables as $table => $fields) {
|
||||
foreach ($fields as $field) {
|
||||
Schema::table($table, static function (Blueprint $table) use ($field): void {
|
||||
// add amount column
|
||||
$table->dropColumn($field);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user