Refactor database migrations and update environment variables handling

This commit is contained in:
Andras Bacsai
2024-10-21 14:15:31 +02:00
parent 0124120e63
commit 3b12d63f49

View File

@@ -4,6 +4,7 @@ use App\Models\EnvironmentVariable;
use App\Models\Server; use App\Models\Server;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Visus\Cuid2\Cuid2; use Visus\Cuid2\Cuid2;
@@ -14,6 +15,7 @@ return new class extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::table('applications', function (Blueprint $table) { Schema::table('applications', function (Blueprint $table) {
$table->dropColumn('docker_compose_pr_location'); $table->dropColumn('docker_compose_pr_location');
$table->dropColumn('docker_compose_pr'); $table->dropColumn('docker_compose_pr');
@@ -47,11 +49,11 @@ return new class extends Migration
Schema::table('server_settings', function (Blueprint $table) { Schema::table('server_settings', function (Blueprint $table) {
$table->integer('metrics_history_days')->default(7)->change(); $table->integer('metrics_history_days')->default(7)->change();
}); });
Server::all()->each(function (Server $server) {
$server->settings->update([ DB::table('server_settings')->update(['metrics_history_days' => 7]);
'metrics_history_days' => 7, } catch (\Exception $e) {
]); loggy($e);
}); }
} }
/** /**