<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.1.xsd">

    <changeSet id="milestone-01-tables" author="dmiller" dbms="oracle,postgresql,mssql">
        <createTable tableName="acm_milestone">
            <column name="cm_milestone_id" type="${idType}">
                <constraints primaryKey="true" primaryKeyName="pk_acm_milestone"/>
            </column>
            <column name="cm_milestone_object_id" type="${fkIdType}">
                <constraints nullable="false"/>
            </column>
            <column name="cm_milestone_object_type" type="VARCHAR(1024)">
                <constraints nullable="false"/>
            </column>
            <column name="cm_milestone_achieved_date" type="${timestampType}">
                <constraints nullable="false"/>
            </column>
            <column name="cm_milestone_name" type="VARCHAR(512)">
                <constraints nullable="false"/>
            </column>
            <column name="cm_milestone_created" type="${timestampType}">
                <constraints nullable="false"/>
            </column>
            <column name="cm_milestone_creator" type="VARCHAR(1024)">
                <constraints nullable="false"/>
            </column>
            <column name="cm_milestone_modified" type="${timestampType}">
                <constraints nullable="false"/>
            </column>
            <column name="cm_milestone_modifier" type="VARCHAR(1024)">
                <constraints nullable="false"/>
            </column>
        </createTable>
    </changeSet>

    <changeSet id="milestone-01-tables" author="dmiller" dbms="mysql">
        <createTable tableName="acm_milestone">
            <column name="cm_milestone_id" type="${idType}">
                <constraints primaryKey="true" primaryKeyName="pk_acm_milestone"/>
            </column>
            <column name="cm_milestone_object_id" type="${fkIdType}">
                <constraints nullable="false"/>
            </column>
            <column name="cm_milestone_object_type" type="VARCHAR(1024)">
                <constraints nullable="false"/>
            </column>
            <column name="cm_milestone_achieved_date" type="${timestampType}" defaultValueComputed="${timestampFunction}">
                <constraints nullable="false"/>
            </column>
            <column name="cm_milestone_name" type="VARCHAR(512)">
                <constraints nullable="false"/>
            </column>
            <column name="cm_milestone_created" type="${timestampType}" defaultValueComputed="${timestampFunction}">
                <constraints nullable="false"/>
            </column>
            <column name="cm_milestone_creator" type="VARCHAR(1024)">
                <constraints nullable="false"/>
            </column>
            <column name="cm_milestone_modified" type="${timestampType}" defaultValueComputed="${timestampFunction}">
                <constraints nullable="false"/>
            </column>
            <column name="cm_milestone_modifier" type="VARCHAR(1024)">
                <constraints nullable="false"/>
            </column>
        </createTable>
    </changeSet>

    <changeSet id="milestone-02-indexes" author="dmiller">
        <createIndex tableName="acm_milestone" indexName="idx_milestone_object_id">
            <column name="cm_milestone_object_id"/>
        </createIndex>
    </changeSet>

    <changeSet id="03-acm_milestone-id" author="nebojsha.davidovikj">
        <createTable tableName="acm_milestone_id">
            <column name="cm_seq_num" type="${idType}"/>
            <column name="cm_seq_name" type="VARCHAR(255)"/>
        </createTable>
        <insert tableName="acm_milestone_id">
            <column name="cm_seq_num" value="100"></column>
            <column name="cm_seq_name" value="acm_milestone"></column>
        </insert>
    </changeSet>

    <changeSet id="01-change_cm_milestone_achieved_date" author="mario.gjurcheski" dbms="mysql">
        <modifyDataType tableName="acm_milestone" columnName="cm_milestone_achieved_date" newDataType="DATETIME"/>
        <modifyDataType tableName="acm_milestone" columnName="cm_milestone_created" newDataType="DATETIME"/>
        <modifyDataType tableName="acm_milestone" columnName="cm_milestone_modified" newDataType="DATETIME"/>
    </changeSet>
</databaseChangeLog>