-- Broadcast Admin Panel: расширяем broadcast_campaign + пункт меню
-- Run: mysql -u kadrum_admin -p dev_kadrum < migrations/20260312_broadcast_admin.sql

-- 1) Добавляем новые колонки
ALTER TABLE broadcast_campaign
    ADD COLUMN `name` VARCHAR(255) DEFAULT '' AFTER `code`,
    ADD COLUMN `filters_json` TEXT NULL AFTER `payload_json`,
    ADD COLUMN `quiet_hours_from` TINYINT NULL DEFAULT NULL AFTER `filters_json`,
    ADD COLUMN `quiet_hours_to` TINYINT NULL DEFAULT NULL AFTER `quiet_hours_from`,
    ADD COLUMN `interval_minutes` INT NOT NULL DEFAULT 0 AFTER `quiet_hours_to`,
    ADD COLUMN `for_new_users_only` TINYINT(1) NOT NULL DEFAULT 0 AFTER `interval_minutes`,
    ADD COLUMN `send_main_keyboard` TINYINT(1) NOT NULL DEFAULT 0 AFTER `for_new_users_only`,
    ADD COLUMN `total_count` INT NOT NULL DEFAULT 0 AFTER `send_main_keyboard`,
    ADD COLUMN `is_active` TINYINT(1) NOT NULL DEFAULT 1 AFTER `total_count`;

-- 2) Пункт меню
INSERT INTO model_names (code, name, vin_name, rod_name, menu_name, rule, sort, parent_id)
VALUES ('broadcast', 'Рассылки', 'рассылку', 'рассылки', 'Рассылки', 'root', 50, NULL);
