SET NAMES utf8mb4;

ALTER TABLE `tb_approval_flow_step`
    ADD COLUMN `restrict_to_applicant_dept` TINYINT NOT NULL DEFAULT 0
        COMMENT '是否限定发起人直属部门' AFTER `assignee_target_name`;

ALTER TABLE `tb_approval_instance`
    ADD COLUMN `applicant_dept_id` BIGINT UNSIGNED NULL
        COMMENT '提交时申请人直属部门ID' AFTER `applicant_id`,
    ADD COLUMN `applicant_dept_name` VARCHAR(128) NULL
        COMMENT '提交时申请人直属部门名称' AFTER `applicant_dept_id`;

ALTER TABLE `tb_approval_task`
    ADD COLUMN `required_dept_id` BIGINT UNSIGNED NULL
        COMMENT '限定直属部门ID' AFTER `assignee_target_name`;

CREATE INDEX `idx_approval_task_required_dept_status`
    ON `tb_approval_task` (`required_dept_id`, `status`);
