Fix: graceful handling of missing modpack_installations table
- Cron and controller wrap modpack_installations queries in try/catch - Falls through to egg variable / file detection if table missing - Added migration with IF NOT EXISTS for fresh installs - Migration won't drop the table (may be Pterodactyl-owned) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a256aa2090
commit
1783055c99
@@ -69,13 +69,18 @@ class CheckModpackUpdates extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Step 1: modpack_installations table (fastest, most reliable)
|
// Step 1: modpack_installations table (fastest, most reliable)
|
||||||
$installation = DB::table('modpack_installations')
|
// This is a Pterodactyl table — may not exist on all panels
|
||||||
->where('server_id', $server->id)
|
try {
|
||||||
->first();
|
$installation = DB::table('modpack_installations')
|
||||||
|
->where('server_id', $server->id)
|
||||||
|
->first();
|
||||||
|
|
||||||
if ($installation && !empty($installation->provider) && !empty($installation->modpack_id)) {
|
if ($installation && !empty($installation->provider) && !empty($installation->modpack_id)) {
|
||||||
$this->checkVersion($server, $installation->provider, (string) $installation->modpack_id, 'installer', null);
|
$this->checkVersion($server, $installation->provider, (string) $installation->modpack_id, 'installer', null);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Table doesn't exist — skip this detection method
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2: Egg variables
|
// Step 2: Egg variables
|
||||||
|
|||||||
@@ -92,14 +92,18 @@ class ModpackAPIController extends Controller
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Check modpack_installations table
|
// 2. Check modpack_installations table (Pterodactyl — may not exist)
|
||||||
if (empty($platform) || empty($modpackId)) {
|
if (empty($platform) || empty($modpackId)) {
|
||||||
$installation = DB::table('modpack_installations')
|
try {
|
||||||
->where('server_id', $server->id)
|
$installation = DB::table('modpack_installations')
|
||||||
->first();
|
->where('server_id', $server->id)
|
||||||
if ($installation) {
|
->first();
|
||||||
$platform = $platform ?: ($installation->provider ?? null);
|
if ($installation) {
|
||||||
$modpackId = $modpackId ?: (string) ($installation->modpack_id ?? '');
|
$platform = $platform ?: ($installation->provider ?? null);
|
||||||
|
$modpackId = $modpackId ?: (string) ($installation->modpack_id ?? '');
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Table doesn't exist on this panel — skip
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates modpack_installations if it doesn't already exist.
|
||||||
|
* This table is normally created by Pterodactyl's modpack installer,
|
||||||
|
* but may be missing on panels without that feature.
|
||||||
|
* Safe to run on panels that already have it.
|
||||||
|
*/
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
if (!Schema::hasTable('modpack_installations')) {
|
||||||
|
Schema::create('modpack_installations', function (Blueprint $table) {
|
||||||
|
$table->unsignedBigInteger('server_id')->primary();
|
||||||
|
$table->string('provider', 191);
|
||||||
|
$table->string('modpack_id', 191);
|
||||||
|
$table->tinyInteger('finalized')->default(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
// Don't drop — this may be a Pterodactyl-owned table
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user