CREATE TABLE IF NOT EXISTS gc_role_menu_permission (
    id       BIGINT       NOT NULL AUTO_INCREMENT,
    role     VARCHAR(20)  NOT NULL COMMENT 'ADMIN | USER | GUEST',
    menu_id  VARCHAR(50)  NOT NULL,
    allowed  TINYINT(1)   NOT NULL DEFAULT 1,
    PRIMARY KEY (id),
    UNIQUE KEY uk_role_menu (role, menu_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
  COMMENT='역할별 메뉴 접근 권한';

-- ADMIN: 전체 허용
INSERT INTO gc_role_menu_permission (role, menu_id, allowed) VALUES
('ADMIN', 'dashboard', 1), ('ADMIN', 'chart', 1), ('ADMIN', 'paper', 1),
('ADMIN', 'strategy', 1), ('ADMIN', 'backtest', 1), ('ADMIN', 'notifications', 1),
('ADMIN', 'settings', 1),
('ADMIN', 'settings_general', 1), ('ADMIN', 'settings_chart', 1),
('ADMIN', 'settings_indicators', 1), ('ADMIN', 'settings_backtest', 1),
('ADMIN', 'settings_strategy', 1), ('ADMIN', 'settings_paper', 1),
('ADMIN', 'settings_alert', 1), ('ADMIN', 'settings_network', 1),
('ADMIN', 'settings_admin', 1);

-- USER: 관리자 설정 제외
INSERT INTO gc_role_menu_permission (role, menu_id, allowed) VALUES
('USER', 'dashboard', 1), ('USER', 'chart', 1), ('USER', 'paper', 1),
('USER', 'strategy', 1), ('USER', 'backtest', 1), ('USER', 'notifications', 1),
('USER', 'settings', 1),
('USER', 'settings_general', 1), ('USER', 'settings_chart', 1),
('USER', 'settings_indicators', 1), ('USER', 'settings_backtest', 1),
('USER', 'settings_strategy', 1), ('USER', 'settings_paper', 1),
('USER', 'settings_alert', 1), ('USER', 'settings_network', 1),
('USER', 'settings_admin', 0);

-- GUEST: 차트·설정(일부)만
INSERT INTO gc_role_menu_permission (role, menu_id, allowed) VALUES
('GUEST', 'dashboard', 0), ('GUEST', 'chart', 1), ('GUEST', 'paper', 0),
('GUEST', 'strategy', 0), ('GUEST', 'backtest', 0), ('GUEST', 'notifications', 0),
('GUEST', 'settings', 1),
('GUEST', 'settings_general', 1), ('GUEST', 'settings_chart', 1),
('GUEST', 'settings_indicators', 0), ('GUEST', 'settings_backtest', 0),
('GUEST', 'settings_strategy', 0), ('GUEST', 'settings_paper', 0),
('GUEST', 'settings_alert', 0), ('GUEST', 'settings_network', 1),
('GUEST', 'settings_admin', 0);
