Panel/modules/billing/add_remote_server_enabled_column.sql
copilot-swe-agent[bot] bb77620796
fix: resolve 3 billing admin errors and normalize remote_servers query
- admin_config.php: guard session_start() — was firing Notice because
  admin_auth.php → session_bridge.php already started the session
- includes/menu.php: check mysqli_thread_id() before reusing $db so a
  closed handle does not cause 'mysqli object is already closed' fatal
- admin_invoices.php / admin_payments.php: set $db = null after
  mysqli_close() so menu.php's reuse-check correctly falls through to
  opening a fresh connection
- adminserverlist.php: use col_exists() to detect missing 'enabled'
  column in gsp_remote_servers; fall back to constant 1 and display a
  schema-notice banner; guard UPDATE accordingly; also add missing
  price_daily / price_year columns to the services SELECT; remove
  duplicate 'Update Enabled Servers' button
- add_remote_server_enabled_column.sql: idempotent migration to add the
  'enabled' INT column to gsp_remote_servers on older installs

Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/988997ed-7568-48bf-96ef-889fb5d91fec

Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
2026-05-02 13:40:10 +00:00

31 lines
1.1 KiB
SQL

-- Migration: add `enabled` column to gsp_remote_servers
--
-- The original panel schema (panel.sql / ogp_remote_servers) includes an `enabled`
-- INT(11) column. Installations that were created from an older schema, or whose
-- table was renamed without carrying the column forward, may be missing it.
--
-- Run this once against your panel database (replace `gsp_` with your prefix if
-- different). Safe to skip if the column already exists — just check with:
-- SHOW COLUMNS FROM `gsp_remote_servers` LIKE 'enabled';
--
-- Usage:
-- mysql -u <user> -p <db_name> < modules/billing/add_remote_server_enabled_column.sql
SET @table_name = 'gsp_remote_servers';
SET @col_name = 'enabled';
SET @sql = IF(
(
SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = @table_name
AND COLUMN_NAME = @col_name
) = 0,
CONCAT('ALTER TABLE `', @table_name, '` ADD COLUMN `enabled` INT(11) NOT NULL DEFAULT 1'),
'SELECT "Column already exists — nothing to do" AS note'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;