Merge branch 'next' into docker-network-aliases

This commit is contained in:
Piotr Wójcik
2025-03-16 14:50:26 +01:00
committed by GitHub
556 changed files with 74674 additions and 5618 deletions

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Visus\Cuid2\Cuid2;
return new class extends Migration
{
public function up(): void
{
Schema::table('environments', function (Blueprint $table) {
$table->string('uuid')->after('id')->nullable()->unique();
});
DB::table('environments')
->whereNull('uuid')
->chunkById(100, function ($environments) {
foreach ($environments as $environment) {
DB::table('environments')
->where('id', $environment->id)
->update(['uuid' => (string) new Cuid2]);
}
});
Schema::table('environments', function (Blueprint $table) {
$table->string('uuid')->nullable(false)->change();
});
}
public function down(): void
{
Schema::table('environments', function (Blueprint $table) {
$table->dropColumn('uuid');
});
}
};

View File

@@ -0,0 +1,165 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('environment_variables', function (Blueprint $table) {
$table->string('resourceable_type')->nullable();
$table->unsignedBigInteger('resourceable_id')->nullable();
$table->index(['resourceable_type', 'resourceable_id']);
});
// Populate the new columns
DB::table('environment_variables')->whereNotNull('application_id')
->update([
'resourceable_type' => 'App\\Models\\Application',
'resourceable_id' => DB::raw('application_id'),
]);
DB::table('environment_variables')->whereNotNull('service_id')
->update([
'resourceable_type' => 'App\\Models\\Service',
'resourceable_id' => DB::raw('service_id'),
]);
DB::table('environment_variables')->whereNotNull('standalone_postgresql_id')
->update([
'resourceable_type' => 'App\\Models\\StandalonePostgresql',
'resourceable_id' => DB::raw('standalone_postgresql_id'),
]);
DB::table('environment_variables')->whereNotNull('standalone_redis_id')
->update([
'resourceable_type' => 'App\\Models\\StandaloneRedis',
'resourceable_id' => DB::raw('standalone_redis_id'),
]);
DB::table('environment_variables')->whereNotNull('standalone_mongodb_id')
->update([
'resourceable_type' => 'App\\Models\\StandaloneMongodb',
'resourceable_id' => DB::raw('standalone_mongodb_id'),
]);
DB::table('environment_variables')->whereNotNull('standalone_mysql_id')
->update([
'resourceable_type' => 'App\\Models\\StandaloneMysql',
'resourceable_id' => DB::raw('standalone_mysql_id'),
]);
DB::table('environment_variables')->whereNotNull('standalone_mariadb_id')
->update([
'resourceable_type' => 'App\\Models\\StandaloneMariadb',
'resourceable_id' => DB::raw('standalone_mariadb_id'),
]);
DB::table('environment_variables')->whereNotNull('standalone_keydb_id')
->update([
'resourceable_type' => 'App\\Models\\StandaloneKeydb',
'resourceable_id' => DB::raw('standalone_keydb_id'),
]);
DB::table('environment_variables')->whereNotNull('standalone_dragonfly_id')
->update([
'resourceable_type' => 'App\\Models\\StandaloneDragonfly',
'resourceable_id' => DB::raw('standalone_dragonfly_id'),
]);
DB::table('environment_variables')->whereNotNull('standalone_clickhouse_id')
->update([
'resourceable_type' => 'App\\Models\\StandaloneClickhouse',
'resourceable_id' => DB::raw('standalone_clickhouse_id'),
]);
// After successful migration, we can drop the old foreign key columns
Schema::table('environment_variables', function (Blueprint $table) {
$table->dropColumn([
'application_id',
'service_id',
'standalone_postgresql_id',
'standalone_redis_id',
'standalone_mongodb_id',
'standalone_mysql_id',
'standalone_mariadb_id',
'standalone_keydb_id',
'standalone_dragonfly_id',
'standalone_clickhouse_id',
]);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('environment_variables', function (Blueprint $table) {
// Restore the old columns
$table->unsignedBigInteger('application_id')->nullable();
$table->unsignedBigInteger('service_id')->nullable();
$table->unsignedBigInteger('standalone_postgresql_id')->nullable();
$table->unsignedBigInteger('standalone_redis_id')->nullable();
$table->unsignedBigInteger('standalone_mongodb_id')->nullable();
$table->unsignedBigInteger('standalone_mysql_id')->nullable();
$table->unsignedBigInteger('standalone_mariadb_id')->nullable();
$table->unsignedBigInteger('standalone_keydb_id')->nullable();
$table->unsignedBigInteger('standalone_dragonfly_id')->nullable();
$table->unsignedBigInteger('standalone_clickhouse_id')->nullable();
});
Schema::table('environment_variables', function (Blueprint $table) {
// Restore data from polymorphic relationship
DB::table('environment_variables')
->where('resourceable_type', 'App\\Models\\Application')
->update(['application_id' => DB::raw('resourceable_id')]);
DB::table('environment_variables')
->where('resourceable_type', 'App\\Models\\Service')
->update(['service_id' => DB::raw('resourceable_id')]);
DB::table('environment_variables')
->where('resourceable_type', 'App\\Models\\StandalonePostgresql')
->update(['standalone_postgresql_id' => DB::raw('resourceable_id')]);
DB::table('environment_variables')
->where('resourceable_type', 'App\\Models\\StandaloneRedis')
->update(['standalone_redis_id' => DB::raw('resourceable_id')]);
DB::table('environment_variables')
->where('resourceable_type', 'App\\Models\\StandaloneMongodb')
->update(['standalone_mongodb_id' => DB::raw('resourceable_id')]);
DB::table('environment_variables')
->where('resourceable_type', 'App\\Models\\StandaloneMysql')
->update(['standalone_mysql_id' => DB::raw('resourceable_id')]);
DB::table('environment_variables')
->where('resourceable_type', 'App\\Models\\StandaloneMariadb')
->update(['standalone_mariadb_id' => DB::raw('resourceable_id')]);
DB::table('environment_variables')
->where('resourceable_type', 'App\\Models\\StandaloneKeydb')
->update(['standalone_keydb_id' => DB::raw('resourceable_id')]);
DB::table('environment_variables')
->where('resourceable_type', 'App\\Models\\StandaloneDragonfly')
->update(['standalone_dragonfly_id' => DB::raw('resourceable_id')]);
DB::table('environment_variables')
->where('resourceable_type', 'App\\Models\\StandaloneClickhouse')
->update(['standalone_clickhouse_id' => DB::raw('resourceable_id')]);
// Drop the polymorphic columns
$table->dropIndex(['resourceable_type', 'resourceable_id']);
$table->dropColumn(['resourceable_type', 'resourceable_id']);
});
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('server_settings', function (Blueprint $table) {
$table->string('server_disk_usage_check_frequency')->default('0 23 * * *');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('server_settings', function (Blueprint $table) {
$table->dropColumn('server_disk_usage_check_frequency');
});
}
};

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
DB::table('application_settings')
->update([
'is_container_label_readonly_enabled' => DB::raw('NOT is_container_label_readonly_enabled'),
]);
Schema::table('application_settings', function (Blueprint $table) {
$table->boolean('is_container_label_readonly_enabled')->default(true)->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
DB::table('application_settings')
->update([
'is_container_label_readonly_enabled' => DB::raw('NOT is_container_label_readonly_enabled'),
]);
Schema::table('application_settings', function (Blueprint $table) {
$table->boolean('is_container_label_readonly_enabled')->default(false)->change();
});
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('application_deployment_queues', function (Blueprint $table) {
$table->string('horizon_job_id')->nullable();
$table->string('horizon_job_worker')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('application_deployment_queues', function (Blueprint $table) {
$table->dropColumn('horizon_job_id');
$table->dropColumn('horizon_job_worker');
});
}
};

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::table('scheduled_database_backups', function (Blueprint $table) {
$table->renameColumn('number_of_backups_locally', 'database_backup_retention_amount_locally');
$table->integer('database_backup_retention_amount_locally')->default(0)->nullable(false)->change();
$table->integer('database_backup_retention_days_locally')->default(0)->nullable(false);
$table->decimal('database_backup_retention_max_storage_locally', 17, 7)->default(0)->nullable(false);
$table->integer('database_backup_retention_amount_s3')->default(0)->nullable(false);
$table->integer('database_backup_retention_days_s3')->default(0)->nullable(false);
$table->decimal('database_backup_retention_max_storage_s3', 17, 7)->default(0)->nullable(false);
});
}
public function down()
{
Schema::table('scheduled_database_backups', function (Blueprint $table) {
$table->renameColumn('database_backup_retention_amount_locally', 'number_of_backups_locally')->nullable(true)->change();
$table->dropColumn([
'database_backup_retention_days_locally',
'database_backup_retention_max_storage_locally',
'database_backup_retention_amount_s3',
'database_backup_retention_days_s3',
'database_backup_retention_max_storage_s3',
]);
});
}
};

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('docker_cleanup_executions', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->enum('status', ['success', 'failed', 'running'])->default('running');
$table->text('message')->nullable();
$table->json('cleanup_log')->nullable();
$table->foreignId('server_id');
$table->timestamps();
$table->timestamp('finished_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('docker_cleanup_executions');
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('application_deployment_queues', function (Blueprint $table) {
$table->text('commit_message')->nullable()->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('application_deployment_queues', function (Blueprint $table) {
$table->string('commit_message', 50)->nullable()->change();
});
}
};

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::table('application_deployment_queues', function (Blueprint $table) {
$table->timestamp('finished_at')->nullable();
});
Schema::table('scheduled_database_backup_executions', function (Blueprint $table) {
$table->timestamp('finished_at')->nullable();
});
Schema::table('scheduled_task_executions', function (Blueprint $table) {
$table->timestamp('finished_at')->nullable();
});
}
public function down()
{
Schema::table('application_deployment_queues', function (Blueprint $table) {
$table->dropColumn('finished_at');
});
Schema::table('scheduled_database_backup_executions', function (Blueprint $table) {
$table->dropColumn('finished_at');
});
Schema::table('scheduled_task_executions', function (Blueprint $table) {
$table->dropColumn('finished_at');
});
}
};

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
try {
DB::table('application_deployment_queues')
->whereNull('finished_at')
->update(['finished_at' => DB::raw('updated_at')]);
} catch (\Exception $e) {
\Log::error('Failed to update not set finished_at timestamps for application_deployment_queues: '.$e->getMessage());
}
try {
DB::table('scheduled_database_backup_executions')
->whereNull('finished_at')
->update(['finished_at' => DB::raw('updated_at')]);
} catch (\Exception $e) {
\Log::error('Failed to update not set finished_at timestamps for scheduled_database_backup_executions: '.$e->getMessage());
}
try {
DB::table('scheduled_task_executions')
->whereNull('finished_at')
->update(['finished_at' => DB::raw('updated_at')]);
} catch (\Exception $e) {
\Log::error('Failed to update not set finished_at timestamps for scheduled_task_executions: '.$e->getMessage());
}
}
};

View File

@@ -0,0 +1,19 @@
<?php
use App\Models\EnvironmentVariable;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Log;
return new class extends Migration
{
public function up(): void
{
try {
EnvironmentVariable::whereNull('resourceable_id')->each(function (EnvironmentVariable $environmentVariable) {
$environmentVariable->delete();
});
} catch (\Exception $e) {
Log::error('Failed to delete wrongly created environment variables: '.$e->getMessage());
}
}
};

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('scheduled_task_executions', function (Blueprint $table) {
$table->index(['scheduled_task_id', 'created_at'], 'scheduled_task_executions_task_id_created_at_index');
});
Schema::table('scheduled_database_backup_executions', function (Blueprint $table) {
$table->index(
['scheduled_database_backup_id', 'created_at'],
'scheduled_db_backup_executions_backup_id_created_at_index'
);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('scheduled_task_executions', function (Blueprint $table) {
$table->dropIndex('scheduled_task_executions_task_id_created_at_index');
});
Schema::table('scheduled_database_backup_executions', function (Blueprint $table) {
$table->dropIndex('scheduled_db_backup_executions_backup_id_created_at_index');
});
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('subscriptions', function (Blueprint $table) {
$table->boolean('stripe_past_due')->default(false);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('subscriptions', function (Blueprint $table) {
$table->dropColumn('stripe_past_due');
});
}
};

View File

@@ -0,0 +1,19 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('scheduled_database_backup_executions', function (Blueprint $table) {
$table->boolean('local_storage_deleted')->default(false);
$table->boolean('s3_storage_deleted')->default(false);
});
}
};