diff --git a/database/migrations/2026_10_28_211105_add_indexes_for_team_deployments_and_docker_cleanup_history.php b/database/migrations/2026_10_28_211105_add_indexes_for_team_deployments_and_docker_cleanup_history.php new file mode 100644 index 0000000000..d8f4b66752 --- /dev/null +++ b/database/migrations/2026_10_28_211105_add_indexes_for_team_deployments_and_docker_cleanup_history.php @@ -0,0 +1,55 @@ +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'); + }); + } + } +};