mirror of
https://github.com/coollabsio/coolify.git
synced 2026-06-13 19:09:50 +00:00
fix(migrations): guard uuid column addition and filter teamless servers
- Skip uuid column creation if it already exists to prevent duplicate
column errors on re-run
- Use chunkById instead of orderBy+chunk for efficient pagination
- Filter servers by whereHas('team') to avoid processing orphaned servers
without a team relationship
This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Server::query()->chunk(100, function ($servers) {
|
||||
Server::query()->whereHas('team')->chunk(100, function ($servers) {
|
||||
foreach ($servers as $server) {
|
||||
$existingKeys = SharedEnvironmentVariable::where('type', 'server')
|
||||
->where('server_id', $server->id)
|
||||
|
||||
+6
-5
@@ -10,14 +10,15 @@ return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('local_persistent_volumes', function (Blueprint $table) {
|
||||
$table->string('uuid')->nullable()->after('id');
|
||||
});
|
||||
if (! Schema::hasColumn('local_persistent_volumes', 'uuid')) {
|
||||
Schema::table('local_persistent_volumes', function (Blueprint $table) {
|
||||
$table->string('uuid')->nullable()->after('id');
|
||||
});
|
||||
}
|
||||
|
||||
DB::table('local_persistent_volumes')
|
||||
->whereNull('uuid')
|
||||
->orderBy('id')
|
||||
->chunk(1000, function ($volumes) {
|
||||
->chunkById(1000, function ($volumes) {
|
||||
foreach ($volumes as $volume) {
|
||||
DB::table('local_persistent_volumes')
|
||||
->where('id', $volume->id)
|
||||
|
||||
Reference in New Issue
Block a user