mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-04 10:42:23 +00:00
fix(database): index team deployment and Docker cleanup history lookups
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
06747f9954
commit
0951c5daa1
1 file changed
+55
+55
@@ -0,0 +1,55 @@
|
||||
<?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
|
||||
{
|
||||
public $withinTransaction = false;
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
if (DB::getDriverName() === 'pgsql') {
|
||||
DB::statement('CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_applications_environment_id_all ON applications (environment_id)');
|
||||
DB::statement('CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_docker_cleanup_executions_server_created_at ON docker_cleanup_executions (server_id, created_at DESC)');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (! Schema::hasIndex('applications', 'idx_applications_environment_id_all')) {
|
||||
Schema::table('applications', function (Blueprint $table) {
|
||||
$table->index('environment_id', 'idx_applications_environment_id_all');
|
||||
});
|
||||
}
|
||||
|
||||
if (! Schema::hasIndex('docker_cleanup_executions', 'idx_docker_cleanup_executions_server_created_at')) {
|
||||
Schema::table('docker_cleanup_executions', function (Blueprint $table) {
|
||||
$table->index(['server_id', 'created_at'], 'idx_docker_cleanup_executions_server_created_at');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (DB::getDriverName() === 'pgsql') {
|
||||
DB::statement('DROP INDEX CONCURRENTLY IF EXISTS idx_docker_cleanup_executions_server_created_at');
|
||||
DB::statement('DROP INDEX CONCURRENTLY IF EXISTS idx_applications_environment_id_all');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (Schema::hasIndex('docker_cleanup_executions', 'idx_docker_cleanup_executions_server_created_at')) {
|
||||
Schema::table('docker_cleanup_executions', function (Blueprint $table) {
|
||||
$table->dropIndex('idx_docker_cleanup_executions_server_created_at');
|
||||
});
|
||||
}
|
||||
|
||||
if (Schema::hasIndex('applications', 'idx_applications_environment_id_all')) {
|
||||
Schema::table('applications', function (Blueprint $table) {
|
||||
$table->dropIndex('idx_applications_environment_id_all');
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user