USE whp;

-- Idempotent additive column on client_allowances. When 1, CPU and memory
-- caps are not enforced for the user. Disk, email, mail storage, and archival
-- caps remain enforced regardless of this flag.

SET @col_exists := (
    SELECT COUNT(*)
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_SCHEMA = 'whp'
      AND TABLE_NAME = 'client_allowances'
      AND COLUMN_NAME = 'uncapped_resources'
);

SET @ddl := IF(@col_exists = 0,
    'ALTER TABLE whp.client_allowances ADD COLUMN uncapped_resources TINYINT(1) NOT NULL DEFAULT 0 COMMENT ''When 1, CPU and memory caps are not enforced for this user (dedicated-server scenario)''',
    'SELECT 1');

PREPARE stmt FROM @ddl;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
