<?php
declare(strict_types=1);

return [
    'up' => "
ALTER TABLE `roles`
    ADD COLUMN `category` VARCHAR(50) NULL AFTER `has_all_branches`,
    ADD COLUMN `level` TINYINT UNSIGNED NOT NULL DEFAULT 0 AFTER `category`,
    ADD COLUMN `is_template` TINYINT(1) NOT NULL DEFAULT 0 AFTER `level`;
UPDATE `roles` SET `category` = 'governance', `level` = 0, `is_template` = 1 WHERE `role_code` IN ('super_admin', 'board_member');
UPDATE `roles` SET `category` = 'management', `level` = 1, `is_template` = 1 WHERE `role_code` = 'membership_director';
UPDATE `roles` SET `category` = 'operations', `level` = 2, `is_template` = 1 WHERE `role_code` IN ('membership_officer', 'sales_agent', 'security_officer');
UPDATE `roles` SET `category` = 'finance', `level` = 1, `is_template` = 1 WHERE `role_code` IN ('treasury_manager', 'treasury_officer');
UPDATE `roles` SET `category` = 'audit', `level` = 2, `is_template` = 1 WHERE `role_code` IN ('auditor', 'report_viewer')
",
    'down' => "ALTER TABLE `roles` DROP COLUMN `category`, DROP COLUMN `level`, DROP COLUMN `is_template`",
];
