-- Compatibility patch: add user_id to admins if missing (precedes 001_add_admins_table.sql)
SET @has_col := (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS 
  WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'admins' AND COLUMN_NAME = 'user_id');

-- Only add if column is missing
SET @stmt := IF(@has_col = 0,
  'ALTER TABLE `admins` ADD COLUMN `user_id` INT NULL AFTER `id`',
  'SELECT 1');
PREPARE s FROM @stmt; EXECUTE s; DEALLOCATE PREPARE s;
