CREATE TABLE IF NOT EXISTS `wecom_bot` (
  `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(64) NOT NULL,
  `role` VARCHAR(32) NOT NULL,
  `bot_id` VARCHAR(128) NOT NULL,
  `secret` VARCHAR(256) NOT NULL,
  `avatar_url` VARCHAR(512) NULL,
  `welcome` VARCHAR(1024) NULL,
  `permissions` TEXT NOT NULL,
  `enabled` BOOLEAN NOT NULL DEFAULT true,
  `sort_order` INT NOT NULL DEFAULT 0,
  `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
  `updated_at` DATETIME(3) NOT NULL,
  UNIQUE INDEX `wecom_bot_bot_id_key`(`bot_id`),
  INDEX `wecom_bot_enabled_sort_order_idx`(`enabled`, `sort_order`),
  PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
