<?xml version="1.0" encoding="utf-8"?>

<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
    <changeSet author="shg" id="1619520700565-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="p_point" columnName="area_id"/>
            </not>
        </preConditions>
        <comment>p_point add column area_id</comment>
        <sql>
            ALTER TABLE `p_point`
            ADD COLUMN `area_id` bigint(20) DEFAULT NULL COMMENT '物理区域id（数据来源于装备wl_area）';
        </sql>
    </changeSet>
    <changeSet author="wjk" id="1619683142000-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="p_point" columnName="area_name"/>
            </not>
        </preConditions>
        <comment>p_point add column area_id</comment>
        <sql>
            ALTER TABLE `p_point`
            ADD COLUMN `area_name` varchar(255) DEFAULT NULL COMMENT '物理区域名称（数据来源于装备wl_area）';
        </sql>
    </changeSet>
    
     <changeSet author="maoying" id="16272868380001-1">
        <preConditions onFail="MARK_RAN">
             <columnExists tableName="p_plan_task" columnName="user_dept"/>
        </preConditions>
        <comment>MODIFY user_dept </comment>
        <sql>
           ALTER TABLE `p_plan_task`
			MODIFY COLUMN `user_dept`  varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '人员部门信息';
        </sql>
    </changeSet>
    
    <changeSet author="maoying" id="16272868380001-2">
        <preConditions onFail="MARK_RAN">
             <columnExists tableName="p_plan_task" columnName="user_name"/>
        </preConditions>
        <comment>MODIFY user_name </comment>
        <sql>
           ALTER TABLE `p_plan_task`
			MODIFY COLUMN `user_name`  varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户姓名' ;
        </sql>
    </changeSet>
    
    <changeSet author="maoying" id="16272868380001-3">
        <preConditions onFail="MARK_RAN">
             <columnExists tableName="p_check" columnName="user_id"/>
        </preConditions>
        <comment>MODIFY user_id </comment>
        <sql>
           ALTER TABLE `p_check`
			MODIFY COLUMN `user_id`  varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '巡检人id，有可能有多个以,隔开';
        </sql>
    </changeSet>
    
    <changeSet author="maoying" id="16272868380001-4">
        <preConditions onFail="MARK_RAN">
             <columnExists tableName="p_check" columnName="dep_id"/>
        </preConditions>
        <comment>MODIFY dep_id </comment>
        <sql>
           ALTER TABLE `p_check`
			MODIFY COLUMN `dep_id`  varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '执行部门ids' ;
        </sql>
    </changeSet>
    
    <changeSet author="maoying" id="16272868380001-5">
        <preConditions onFail="MARK_RAN">
             <columnExists tableName="p_check" columnName="dep_name"/>
        </preConditions>
        <comment>MODIFY dep_name </comment>
        <sql>
           ALTER TABLE `p_check`
			MODIFY COLUMN `dep_name`  varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '执行部门名称';
        </sql>
    </changeSet>

    <changeSet author="tb" id="tb-202109101731-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="p_latent_danger" columnName="biz_type"/>
            </not>
        </preConditions>
        <comment>p_latent_danger add COLUMN biz_type '业务类型（不同业务创建的隐患以此区分）'</comment>
        <sql>
            ALTER TABLE p_latent_danger add COLUMN `biz_type` varchar(30) DEFAULT NULL COMMENT '业务类型（不同业务创建的隐患以此区分）' after
            `id`;
        </sql>
    </changeSet>
    <changeSet author="tb" id="tb-202109101731-2">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="p_latent_danger" columnName="longitude"/>
            </not>
        </preConditions>
        <comment>p_latent_danger add COLUMN longitude '隐患地址经度'</comment>
        <sql>
            ALTER TABLE p_latent_danger add COLUMN `longitude` varchar(30) DEFAULT NULL COMMENT '隐患地址经度' after
            `danger_position`;
        </sql>
    </changeSet>
    <changeSet author="tb" id="tb-202109101731-3">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="p_latent_danger" columnName="latitude"/>
            </not>
        </preConditions>
        <comment>p_latent_danger add COLUMN latitude '隐患地址纬度'</comment>
        <sql>
            ALTER TABLE p_latent_danger add COLUMN `latitude` varchar(30) DEFAULT NULL COMMENT '隐患地址纬度' after
            `longitude`;
        </sql>
    </changeSet>

    <changeSet author="tb" id="tb-20211009-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="p_latent_danger" columnName="danger_level_name"/>
            </not>
        </preConditions>
        <comment>p_latent_danger add COLUMN danger_level_name '隐患等级名称'</comment>
        <sql>
            ALTER TABLE p_latent_danger add COLUMN `danger_level_name` varchar(50) DEFAULT NULL COMMENT '隐患等级名称' after
            `danger_level`;
        </sql>
    </changeSet>
    <changeSet author="tb" id="tb-20211009-2">
        <preConditions onFail="MARK_RAN">
            <columnExists tableName="p_latent_danger" columnName="danger_level"/>
        </preConditions>
        <comment>p_latent_danger MODIFY COLUMN danger_level</comment>
        <sql>
            ALTER TABLE p_latent_danger MODIFY COLUMN `danger_level` varchar(30) NOT NULL DEFAULT '1' COMMENT '隐患等级';
        </sql>
    </changeSet>

    <changeSet author="tb" id="tb-20211009-3">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="p_latent_danger" columnName="danger_type_name"/>
            </not>
        </preConditions>
        <comment>p_latent_danger add COLUMN danger_type_name '隐患类型名称'</comment>
        <sql>
            ALTER TABLE p_latent_danger add COLUMN `danger_type_name` varchar(50) DEFAULT NULL COMMENT '隐患类型名称';
        </sql>
    </changeSet>
    <changeSet author="tb" id="tb-20211009-4">
        <preConditions onFail="MARK_RAN">
            <columnExists tableName="p_latent_danger" columnName="danger_type"/>
        </preConditions>
        <comment>p_latent_danger MODIFY COLUMN danger_type</comment>
        <sql>
            ALTER TABLE p_latent_danger MODIFY COLUMN `danger_type` varchar(30) NOT NULL DEFAULT '1' COMMENT '隐患类型（1：无码无计划隐患；2：巡检隐患；3：有码无计划隐患；4：随手拍）';
        </sql>
    </changeSet>

    <changeSet author="tb" id="tb-20211009-5">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="p_latent_danger" columnName="reform_type_name"/>
            </not>
        </preConditions>
        <comment>p_latent_danger add COLUMN reform_type_name '整改类型名称'</comment>
        <sql>
            ALTER TABLE p_latent_danger add COLUMN `reform_type_name` varchar(50) DEFAULT NULL COMMENT '整改类型名称';
        </sql>
    </changeSet>
    <changeSet author="tb" id="tb-20211009-6">
        <preConditions onFail="MARK_RAN">
            <columnExists tableName="p_latent_danger" columnName="reform_type"/>
        </preConditions>
        <comment>p_latent_danger MODIFY COLUMN reform_type</comment>
        <sql>
            ALTER TABLE p_latent_danger MODIFY COLUMN `reform_type` varchar(30) DEFAULT NULL COMMENT '整改类型';
        </sql>
    </changeSet>

    <changeSet author="tb" id="tb-20211009-7">
        <preConditions onFail="MARK_RAN">
            <columnExists tableName="p_latent_danger" columnName="overtime_state"/>
        </preConditions>
        <comment>p_latent_danger MODIFY COLUMN overtime_state</comment>
        <sql>
            ALTER TABLE p_latent_danger MODIFY COLUMN `overtime_state` bit(4) NOT NULL DEFAULT b'0' COMMENT '是否逾期（0：否；1：是）';
        </sql>
    </changeSet>

    <changeSet author="tb" id="tb-20211009-8">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="p_latent_danger" columnName="danger_state_name"/>
            </not>
        </preConditions>
        <comment>p_latent_danger add COLUMN danger_state_name '隐患状态名称'</comment>
        <sql>
            ALTER TABLE p_latent_danger add COLUMN `danger_state_name` varchar(50) DEFAULT NULL COMMENT '隐患状态名称';
        </sql>
    </changeSet>
    <changeSet author="tb" id="tb-20211009-9">
        <preConditions onFail="MARK_RAN">
            <columnExists tableName="p_latent_danger" columnName="danger_state"/>
        </preConditions>
        <comment>p_latent_danger MODIFY COLUMN danger_state</comment>
        <sql>
            ALTER TABLE p_latent_danger MODIFY COLUMN `danger_state` varchar(30) NOT NULL DEFAULT '1' COMMENT '隐患状态';
        </sql>
    </changeSet>

    <changeSet author="tb" id="tb-20211009-10">
        <preConditions onFail="MARK_RAN">
            <columnExists tableName="p_latent_danger" columnName="deleted"/>
        </preConditions>
        <comment>p_latent_danger MODIFY COLUMN deleted</comment>
        <sql>
            ALTER TABLE p_latent_danger MODIFY COLUMN `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除（0：否；1：是）';
        </sql>
    </changeSet>

    <changeSet author="tb" id="tb-20211009-11">
        <preConditions onFail="MARK_RAN">
            <columnExists tableName="p_latent_danger" columnName="check_input_id"/>
        </preConditions>
        <comment>p_latent_danger CHANGE COLUMN check_input_id to biz_id '创建隐患的业务数据主键id'</comment>
        <sql>
            ALTER TABLE p_latent_danger CHANGE COLUMN `check_input_id` `biz_id` bigint(20) DEFAULT NULL COMMENT '创建隐患的业务数据主键id';
        </sql>
    </changeSet>

    <changeSet author="tb" id="tb-20211009-12">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="p_latent_danger" columnName="biz_info"/>
            </not>
        </preConditions>
        <comment>p_latent_danger add COLUMN biz_info '业务信息'</comment>
        <sql>
            ALTER TABLE p_latent_danger add COLUMN `biz_info` varchar(500) DEFAULT NULL COMMENT '业务信息';
        </sql>
    </changeSet>

    <changeSet author="tb" id="tb-20211009-13">
        <preConditions onFail="MARK_RAN">
            <columnExists tableName="p_latent_danger_flow_record" columnName="excute_state"/>
        </preConditions>
        <comment>p_latent_danger_flow_record CHANGE COLUMN excute_state</comment>
        <sql>
            ALTER TABLE p_latent_danger_flow_record CHANGE COLUMN `excute_state` `execute_state` tinyint(4) NOT NULL DEFAULT '1' COMMENT '执行状态（1：未执行；2：通过；3：驳回）';
        </sql>
    </changeSet>

    <changeSet author="tb" id="tb-20211009-14">
        <preConditions onFail="MARK_RAN">
            <columnExists tableName="p_latent_danger_flow_record" columnName="excute_user_id"/>
        </preConditions>
        <comment>p_latent_danger_flow_record CHANGE COLUMN excute_user_id to execute_user_id</comment>
        <sql>
            ALTER TABLE p_latent_danger_flow_record CHANGE COLUMN `excute_user_id` `execute_user_id` varchar(255) DEFAULT NULL COMMENT '执行人';
        </sql>
    </changeSet>

    <changeSet author="tb" id="tb-20211009-15">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="p_latent_danger_flow_record" columnName="execute_user_name"/>
            </not>
        </preConditions>
        <comment>p_latent_danger_flow_record add COLUMN execute_user_name '执行人名称'</comment>
        <sql>
            ALTER TABLE p_latent_danger_flow_record add COLUMN `execute_user_name` varchar(255) DEFAULT NULL COMMENT '执行人名称';
        </sql>
    </changeSet>

    <changeSet author="tb" id="tb-20211009-16">
        <preConditions onFail="MARK_RAN">
            <columnExists tableName="p_latent_danger_flow_record" columnName="excute_department_id"/>
        </preConditions>
        <comment>p_latent_danger_flow_record CHANGE COLUMN excute_department_id to execute_department_id</comment>
        <sql>
            ALTER TABLE p_latent_danger_flow_record CHANGE COLUMN `excute_department_id` `execute_department_id` varchar(255) DEFAULT NULL COMMENT '执行部门编号';
        </sql>
    </changeSet>

    <changeSet author="tb" id="tb-20211009-17">
        <preConditions onFail="MARK_RAN">
            <not>
                <columnExists tableName="p_latent_danger_flow_record" columnName="execute_department_name"/>
            </not>
        </preConditions>
        <comment>p_latent_danger_flow_record add COLUMN execute_department_name '执行部门名称'</comment>
        <sql>
            ALTER TABLE p_latent_danger_flow_record add COLUMN `execute_department_name` varchar(255) DEFAULT NULL COMMENT '执行部门名称';
        </sql>
    </changeSet>

    <changeSet author="tb" id="tb-20211009-18">
        <preConditions onFail="MARK_RAN">
            <columnExists tableName="p_latent_danger_flow_record" columnName="excute_result"/>
        </preConditions>
        <comment>p_latent_danger_flow_record CHANGE COLUMN excute_result to execute_result</comment>
        <sql>
            ALTER TABLE p_latent_danger_flow_record CHANGE COLUMN `excute_result` `execute_result` varchar(255) DEFAULT NULL COMMENT '执行结果';
        </sql>
    </changeSet>

</databaseChangeLog>