-- install/ensure_ceo.sql
-- Creates users table (if missing) and ensures CEO user exists with correct role.

CREATE TABLE IF NOT EXISTS users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  telegram_id BIGINT NOT NULL UNIQUE,
  full_name VARCHAR(200) NULL,
  role ENUM('ceo','accountant','dep_manager','scenario','editor','admin','customer') DEFAULT 'customer',
  is_active TINYINT(1) DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT INTO users (telegram_id, role, is_active)
VALUES (894457439, 'ceo', 1)
ON DUPLICATE KEY UPDATE role='ceo', is_active=1;
