mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
fix(database): index server settings and team membership lookups
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
42ba6ec666
commit
2b6af2744a
+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_server_settings_server_id ON server_settings (server_id)');
|
||||
DB::statement('CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_team_user_user_id ON team_user (user_id)');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (! Schema::hasIndex('server_settings', 'idx_server_settings_server_id')) {
|
||||
Schema::table('server_settings', function (Blueprint $table) {
|
||||
$table->index('server_id', 'idx_server_settings_server_id');
|
||||
});
|
||||
}
|
||||
|
||||
if (! Schema::hasIndex('team_user', 'idx_team_user_user_id')) {
|
||||
Schema::table('team_user', function (Blueprint $table) {
|
||||
$table->index('user_id', 'idx_team_user_user_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (DB::getDriverName() === 'pgsql') {
|
||||
DB::statement('DROP INDEX CONCURRENTLY IF EXISTS idx_team_user_user_id');
|
||||
DB::statement('DROP INDEX CONCURRENTLY IF EXISTS idx_server_settings_server_id');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (Schema::hasIndex('team_user', 'idx_team_user_user_id')) {
|
||||
Schema::table('team_user', function (Blueprint $table) {
|
||||
$table->dropIndex('idx_team_user_user_id');
|
||||
});
|
||||
}
|
||||
|
||||
if (Schema::hasIndex('server_settings', 'idx_server_settings_server_id')) {
|
||||
Schema::table('server_settings', function (Blueprint $table) {
|
||||
$table->dropIndex('idx_server_settings_server_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user