mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
New migration command.
This commit is contained in:
46
database/migrations/2022_08_21_104626_add_user_groups.php
Normal file
46
database/migrations/2022_08_21_104626_add_user_groups.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table(
|
||||
'currency_exchange_rates', function (Blueprint $table) {
|
||||
|
||||
if (!Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
|
||||
$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');
|
||||
$table->foreign('user_group_id', 'cer_to_ugi')->references('id')->on('user_groups')->onDelete('set null')->onUpdate('cascade');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table(
|
||||
'currency_exchange_rates', function (Blueprint $table) {
|
||||
|
||||
$table->dropForeign('cer_to_ugi');
|
||||
if (Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
|
||||
$table->dropColumn('user_group_id');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user