flowable-modeler-app-db-changelog.xml 6.97 KB
Newer Older
Rensq's avatar
Rensq committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
<?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" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
	xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd
        http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

	<changeSet id="1" author="flowable">
		<preConditions onFail="MARK_RAN">
			<not>
				<tableExists tableName="ACT_DE_MODEL"/>
				<tableExists tableName="ACT_DE_MODEL_HISTORY"/>
				<tableExists tableName="ACT_DE_MODEL_RELATION"/>
<!--                <tableExists tableName="ACT_RE_MODEL"/>-->
<!--                <tableExists tableName="ACT_RE_DEPLOYMENT"/>-->
<!--                <tableExists tableName="ACT_RU_EXECUTION"/>-->
<!--                <tableExists tableName="ACT_RE_PROCDEF"/>-->
<!--                <tableExists tableName="ACT_EVT_LOG"/>-->
<!--                <tableExists tableName="ACT_PROCDEF_INFO"/>-->
<!--                <tableExists tableName="ACT_RU_ACTINST"/>-->
			</not>
        </preConditions>
        <!-- model -->
		<createTable tableName="ACT_DE_MODEL">
			<column name="id" type="varchar(255)">
				<constraints primaryKey="true" nullable="false" />
			</column>
			<column name="name" type="varchar(400)">
				<constraints nullable="false" />
			</column>
			<column name="model_key" type="varchar(400)">
				<constraints nullable="false" />
			</column>
			<column name="description" type="varchar(4000)">
				<constraints nullable="true" />
			</column>
			<column name="model_comment" type="varchar(4000)">
				<constraints nullable="true" />
			</column>
			<column name="created" type="datetime(6)">
				<constraints nullable="true" />
			</column>
			<column name="created_by" type="varchar(255)">
				<constraints nullable="true" />
			</column>
			<column name="last_updated" type="datetime(6)">
				<constraints nullable="true" />
			</column>
			<column name="last_updated_by" type="varchar(255)">
				<constraints nullable="true" />
			</column>
			<column name="version" type="int">
				<constraints nullable="true" />
			</column>
			<column name="model_editor_json" type="longtext">
				<constraints nullable="true" />
			</column>
			<column name="thumbnail" type="longblob">
				<constraints nullable="true" />
			</column>
			<column name="model_type" type="int">
                <constraints nullable="true" />
            </column>
		</createTable>
        
        <createIndex indexName="idx_proc_mod_created"
            tableName="ACT_DE_MODEL" unique="false">
            <column name="created_by" />
        </createIndex>
        
        <!-- Model history -->
        <createTable tableName="ACT_DE_MODEL_HISTORY">
            <column name="id" type="varchar(255)">
                <constraints primaryKey="true" nullable="false" />
            </column>
            <column name="name" type="varchar(400)">
                <constraints nullable="false" />
            </column>
            <column name="model_key" type="varchar(400)">
				<constraints nullable="false" />
			</column>
            <column name="description" type="varchar(4000)">
                <constraints nullable="true" />
            </column>
            <column name="model_comment" type="varchar(4000)">
                <constraints nullable="true" />
            </column>
            <column name="created" type="datetime(6)">
                <constraints nullable="true" />
            </column>
            <column name="created_by" type="varchar(255)">
                <constraints nullable="true" />
            </column>
            <column name="last_updated" type="datetime(6)">
                <constraints nullable="true" />
            </column>
            <column name="last_updated_by" type="varchar(255)">
                <constraints nullable="true" />
            </column>
            <column name="removal_date" type="datetime(6)">
                <constraints nullable="true" />
            </column>
            <column name="version" type="int">
                <constraints nullable="true" />
            </column>
            <column name="model_editor_json" type="longtext">
                <constraints nullable="true" />
            </column>
            <column name="model_id" type="varchar(255)">
                <constraints nullable="false" />
            </column>
            <column name="model_type" type="int">
                <constraints nullable="true" />
            </column>
        </createTable>
        
        <createIndex indexName="idx_proc_mod_history_proc"
            tableName="ACT_DE_MODEL_HISTORY" unique="false">
            <column name="model_id" />
        </createIndex>
	
		<!-- MODEL RELATION -->
		
		 <createTable tableName="ACT_DE_MODEL_RELATION">
		 	<column name="id" type="varchar(255)">
                <constraints primaryKey="true" nullable="false" />
            </column>
            <column name="parent_model_id" type="varchar(255)" />
            <column name="model_id" type="varchar(255)" />
            <column name="relation_type" type="varchar(255)" />
        </createTable>
        
        <addForeignKeyConstraint baseColumnNames="parent_model_id"
			baseTableName="ACT_DE_MODEL_RELATION" constraintName="fk_relation_parent"
			referencedColumnNames="id" referencedTableName="ACT_DE_MODEL" />
			
		<addForeignKeyConstraint baseColumnNames="model_id"
			baseTableName="ACT_DE_MODEL_RELATION" constraintName="fk_relation_child"
			referencedColumnNames="id" referencedTableName="ACT_DE_MODEL" />
			
	</changeSet>
    
    <!-- 
        Bugfix: saving a model multiple times can sometimes give a conflict exception on sql server 
        due to the precision storage of the datetime data type. The datetime2 type has a better precision. 
    -->
    <changeSet id="2" author="flowable" dbms="mssql">
    
        <modifyDataType tableName="ACT_DE_MODEL" columnName="created" newDataType="datetime2" />
        <modifyDataType tableName="ACT_DE_MODEL" columnName="last_updated" newDataType="datetime2" />
        
        <modifyDataType tableName="ACT_DE_MODEL_HISTORY" columnName="created" newDataType="datetime2" />
        <modifyDataType tableName="ACT_DE_MODEL_HISTORY" columnName="last_updated" newDataType="datetime2" />
        <modifyDataType tableName="ACT_DE_MODEL_HISTORY" columnName="removal_date" newDataType="datetime2" />
        
    </changeSet>

    <changeSet id="3" author="flowable">
		<preConditions onFail="MARK_RAN">
			<not>
				<columnExists tableName="ACT_DE_MODEL" columnName="tenant_id"/>
				<columnExists tableName="ACT_DE_MODEL_HISTORY" columnName="tenant_id"/>
			</not>
        </preConditions>
        <addColumn tableName="ACT_DE_MODEL">
            <column  name="tenant_id" type="varchar(255)" />
        </addColumn>
        <addColumn tableName="ACT_DE_MODEL_HISTORY">
            <column  name="tenant_id" type="varchar(255)" />
        </addColumn>
    </changeSet>

</databaseChangeLog>