Refactor database migrations and update environment variables handling
This commit is contained in:
@@ -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,44 +15,45 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
Schema::table('applications', function (Blueprint $table) {
|
try {
|
||||||
$table->dropColumn('docker_compose_pr_location');
|
Schema::table('applications', function (Blueprint $table) {
|
||||||
$table->dropColumn('docker_compose_pr');
|
$table->dropColumn('docker_compose_pr_location');
|
||||||
$table->dropColumn('docker_compose_pr_raw');
|
$table->dropColumn('docker_compose_pr');
|
||||||
});
|
$table->dropColumn('docker_compose_pr_raw');
|
||||||
Schema::table('subscriptions', function (Blueprint $table) {
|
});
|
||||||
$table->dropColumn('lemon_subscription_id');
|
Schema::table('subscriptions', function (Blueprint $table) {
|
||||||
$table->dropColumn('lemon_order_id');
|
$table->dropColumn('lemon_subscription_id');
|
||||||
$table->dropColumn('lemon_product_id');
|
$table->dropColumn('lemon_order_id');
|
||||||
$table->dropColumn('lemon_variant_id');
|
$table->dropColumn('lemon_product_id');
|
||||||
$table->dropColumn('lemon_variant_name');
|
$table->dropColumn('lemon_variant_id');
|
||||||
$table->dropColumn('lemon_customer_id');
|
$table->dropColumn('lemon_variant_name');
|
||||||
$table->dropColumn('lemon_status');
|
$table->dropColumn('lemon_customer_id');
|
||||||
$table->dropColumn('lemon_renews_at');
|
$table->dropColumn('lemon_status');
|
||||||
$table->dropColumn('lemon_update_payment_menthod_url');
|
$table->dropColumn('lemon_renews_at');
|
||||||
$table->dropColumn('lemon_trial_ends_at');
|
$table->dropColumn('lemon_update_payment_menthod_url');
|
||||||
$table->dropColumn('lemon_ends_at');
|
$table->dropColumn('lemon_trial_ends_at');
|
||||||
});
|
$table->dropColumn('lemon_ends_at');
|
||||||
Schema::table('environment_variables', function (Blueprint $table) {
|
});
|
||||||
$table->string('uuid')->nullable()->after('id');
|
Schema::table('environment_variables', function (Blueprint $table) {
|
||||||
});
|
$table->string('uuid')->nullable()->after('id');
|
||||||
|
});
|
||||||
|
|
||||||
EnvironmentVariable::all()->each(function (EnvironmentVariable $environmentVariable) {
|
EnvironmentVariable::all()->each(function (EnvironmentVariable $environmentVariable) {
|
||||||
$environmentVariable->update([
|
$environmentVariable->update([
|
||||||
'uuid' => (string) new Cuid2,
|
'uuid' => (string) new Cuid2,
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
Schema::table('environment_variables', function (Blueprint $table) {
|
Schema::table('environment_variables', function (Blueprint $table) {
|
||||||
$table->string('uuid')->nullable(false)->change();
|
$table->string('uuid')->nullable(false)->change();
|
||||||
});
|
});
|
||||||
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);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user