CREATE TABLE IF NOT EXISTS dxbots_bots (
  id INT AUTO_INCREMENT PRIMARY KEY,
  account_id INT NOT NULL,
  discord_bot_id VARCHAR(32) NOT NULL,
  name VARCHAR(100) NOT NULL,
  token_enc TEXT NOT NULL,
  pm2_name VARCHAR(120) NOT NULL,
  base_path VARCHAR(255) NOT NULL,
  status ENUM('pending','running','stopped','error') NOT NULL DEFAULT 'pending',
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  UNIQUE KEY uq_discord_bot (discord_bot_id),
  INDEX idx_account (account_id),
  CONSTRAINT fk_dxbots_bots_account FOREIGN KEY (account_id) REFERENCES dxbots_accounts(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

