-- Migration 139: Server Command Center — server_config table
-- Creates the foundation for short_name-based Discord channel detection
-- and server management from Trinity Console.

CREATE TABLE IF NOT EXISTS server_config (
  server_identifier VARCHAR(36) PRIMARY KEY,
  short_name VARCHAR(64) UNIQUE,
  short_name_locked BOOLEAN DEFAULT false,
  display_name VARCHAR(128),
  subdomain VARCHAR(64) UNIQUE,
  server_ip VARCHAR(45),
  server_port INTEGER DEFAULT 25565,
  restart_enabled BOOLEAN DEFAULT true,
  restart_offset_minutes INTEGER DEFAULT 0,
  node VARCHAR(8),
  pterodactyl_name VARCHAR(128),
  created_at TIMESTAMP DEFAULT NOW(),
  updated_at TIMESTAMP DEFAULT NOW()
);

-- Index for fast short_name lookups (channel detection)
CREATE INDEX IF NOT EXISTS idx_server_config_short_name
  ON server_config (short_name);

-- Index for node-based queries (matrix grouping)
CREATE INDEX IF NOT EXISTS idx_server_config_node
  ON server_config (node);
