exec("ALTER TABLE units ADD COLUMN IF NOT EXISTS cost_resource_id INT NULL AFTER faction_id"); $db->exec("ALTER TABLE units ADD COLUMN IF NOT EXISTS cost_amount INT DEFAULT 1 AFTER cost_resource_id"); $db->exec("ALTER TABLE units ADD COLUMN IF NOT EXISTS destruction_resource_id INT NULL AFTER bonus_destruction"); $db->exec("ALTER TABLE units ADD COLUMN IF NOT EXISTS destruction_amount INT DEFAULT 0 AFTER destruction_resource_id"); $db->exec("ALTER TABLE units ADD COLUMN IF NOT EXISTS capture_resource_id INT NULL AFTER bonus_capture"); $db->exec("ALTER TABLE units ADD COLUMN IF NOT EXISTS capture_amount INT DEFAULT 0 AFTER capture_resource_id"); echo "Migration successful: new resource columns added to 'units' table.\n"; } catch (PDOException $e) { echo "Migration failed: " . $e->getMessage() . "\n"; }