2021-07-17 17:02:58 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
|
|
|
|
class RemoveUserInteraction extends Migration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*/
|
2022-11-25 20:29:04 +00:00
|
|
|
public function up(): void
|
2021-07-17 17:02:58 +00:00
|
|
|
{
|
|
|
|
// Remove User Interaction from startup config
|
2022-11-25 20:29:04 +00:00
|
|
|
switch (DB::getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME)) {
|
|
|
|
case 'mysql':
|
|
|
|
DB::table('eggs')->update([
|
|
|
|
'config_startup' => DB::raw('JSON_REMOVE(config_startup, \'$.userInteraction\')'),
|
|
|
|
]);
|
|
|
|
break;
|
|
|
|
case 'pgsql':
|
|
|
|
DB::table('eggs')->update([
|
|
|
|
'config_startup' => DB::raw('config_startup::jsonb - \'userInteraction\''),
|
|
|
|
]);
|
|
|
|
break;
|
|
|
|
}
|
2021-07-17 17:02:58 +00:00
|
|
|
}
|
|
|
|
|
2022-11-25 20:29:04 +00:00
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*/
|
|
|
|
public function down(): void
|
2021-07-17 17:02:58 +00:00
|
|
|
{
|
|
|
|
// Add blank User Interaction array back to startup config
|
2022-11-25 20:29:04 +00:00
|
|
|
switch (DB::getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME)) {
|
|
|
|
case 'mysql':
|
|
|
|
DB::table('eggs')->update([
|
|
|
|
'config_startup' => DB::raw('JSON_SET(config_startup, \'$.userInteraction\', JSON_ARRAY())'),
|
|
|
|
]);
|
|
|
|
break;
|
|
|
|
case 'pgsql':
|
|
|
|
DB::table('eggs')->update([
|
|
|
|
'config_startup' => DB::raw('jsonb_set(config_startup::jsonb, \'$.userInteraction\', jsonb_build_array())'),
|
|
|
|
]);
|
|
|
|
break;
|
|
|
|
}
|
2021-07-17 17:02:58 +00:00
|
|
|
}
|
|
|
|
}
|