diff --git a/database/migrations/2020_08_03_000000_populate_settings_table.php b/database/migrations/2020_08_03_000000_populate_settings_table.php index 0486ab755e..7332b495ed 100644 --- a/database/migrations/2020_08_03_000000_populate_settings_table.php +++ b/database/migrations/2020_08_03_000000_populate_settings_table.php @@ -2,8 +2,6 @@ use App\Setting; use Illuminate\Database\Migrations\Migration; -use Illuminate\Database\Schema\Blueprint; -use Illuminate\Support\Facades\Schema; class PopulateSettingsTable extends Migration { @@ -112,11 +110,14 @@ public function up() 'legacy.report.remote_factory.password' => null, 'legacy.report.remote_factory.logo_name' => null, ]; - + collect($settings)->each(function ($value, $key) { - Setting::query()->updateOrCreate([ + if (Setting::query()->where('key', $key)->exists()) { + return; + } + + Setting::query()->create([ 'key' => $key, - ], [ 'value' => $value, ]); }); @@ -129,6 +130,6 @@ public function up() */ public function down() { - DB::table('settings')->delete(); + Setting::query()->truncate(); } }