Differential D2815 Diff 8068 src/database/migrations/2021_08_25_120000_greylist_settings_migrate.php
Changeset View
Changeset View
Standalone View
Standalone View
src/database/migrations/2021_08_25_120000_greylist_settings_migrate.php
- This file was added.
<?php | |||||
use Illuminate\Database\Migrations\Migration; | |||||
use Illuminate\Database\Schema\Blueprint; | |||||
use Illuminate\Support\Facades\DB; | |||||
use Illuminate\Support\Facades\Schema; | |||||
// phpcs:ignore | |||||
class GreylistSettingsMigrate extends Migration | |||||
{ | |||||
/** | |||||
* Run the migrations. | |||||
* | |||||
* @return void | |||||
*/ | |||||
public function up() | |||||
{ | |||||
$settings = DB::table('user_settings')->where('key', 'greylist_enabled')->get(); | |||||
foreach ($settings as $setting) { | |||||
DB::table('greylist_settings')->insert([ | |||||
'key' => $setting->key, | |||||
'value' => $setting->value, | |||||
'object_id' => $setting->user_id, | |||||
'object_type' => \App\User::class, | |||||
'created_at' => $setting->created_at, | |||||
'updated_at' => $setting->updated_at, | |||||
]); | |||||
} | |||||
DB::table('user_settings')->where('key', 'greylist_enabled')->delete(); | |||||
} | |||||
/** | |||||
* Reverse the migrations. | |||||
* | |||||
* @return void | |||||
*/ | |||||
public function down() | |||||
{ | |||||
// do nothing | |||||
} | |||||
} |