<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="01-create-acm-authentication-token-table" author="mnj11" dbms="oracle,postgresql,mssql">

        <createTable tableName="acm_authentication_token">

            <column name="cm_authentication_token_id" type="${idType}">
                <constraints primaryKey="true" primaryKeyName="pk_authentication_token"/>
            </column>

            <column name="cm_authentication_token_created" type="${timestampType}">
                <constraints nullable="false"/>
            </column>

            <column name="cm_authentication_token_creator" type="VARCHAR(1024)">
                <constraints nullable="false"/>
            </column>

            <column name="cm_authentication_token_modified" type="${timestampType}">
                <constraints nullable="false"/>
            </column>

            <column name="cm_authentication_token_modifier" type="VARCHAR(1024)">
                <constraints nullable="false"/>
            </column>

            <column name="cm_authentication_token_key" type="VARCHAR(1024)">
                <constraints nullable="false"/>
            </column>

            <column name="cm_authentication_token_email" type="VARCHAR(512)">
                <constraints nullable="false"/>
            </column>

            <column name="cm_authentication_token_password" type="VARCHAR(1024)">
                <constraints nullable="true"/>
            </column>

            <column name="cm_authentication_token_status" type="VARCHAR(1024)">
                <constraints nullable="true"/>
            </column>

            <column name="cm_authentication_token_file_id" type="${fkIdType}">
                <constraints nullable="true"/>
            </column>

        </createTable>
    </changeSet>

    <changeSet id="01-create-acm-authentication-token-table" author="mnj11" dbms="mysql">

        <createTable tableName="acm_authentication_token">

            <column name="cm_authentication_token_id" type="${idType}">
                <constraints primaryKey="true" primaryKeyName="pk_authentication_token"/>
            </column>

            <column name="cm_authentication_token_created" type="${timestampType}" defaultValueComputed="${timestampFunction}">
                <constraints nullable="false"/>
            </column>

            <column name="cm_authentication_token_creator" type="VARCHAR(1024)">
                <constraints nullable="false"/>
            </column>

            <column name="cm_authentication_token_modified" type="${timestampType}" defaultValueComputed="${timestampFunction}">
                <constraints nullable="false"/>
            </column>

            <column name="cm_authentication_token_modifier" type="VARCHAR(1024)">
                <constraints nullable="false"/>
            </column>

            <column name="cm_authentication_token_key" type="VARCHAR(1024)">
                <constraints nullable="false"/>
            </column>

            <column name="cm_authentication_token_email" type="VARCHAR(512)">
                <constraints nullable="false"/>
            </column>

            <column name="cm_authentication_token_password" type="VARCHAR(1024)">
                <constraints nullable="true"/>
            </column>

            <column name="cm_authentication_token_status" type="VARCHAR(1024)">
                <constraints nullable="true"/>
            </column>

            <column name="cm_authentication_token_file_id" type="${fkIdType}">
                <constraints nullable="true"/>
            </column>

        </createTable>
    </changeSet>

    <changeSet id="02-change_cm_authentication_token_datetime" author="mario.gjurcheski" dbms="mysql">
        <modifyDataType tableName="acm_authentication_token" columnName="cm_authentication_token_created" newDataType="DATETIME"/>
        <modifyDataType tableName="acm_authentication_token" columnName="cm_authentication_token_modified" newDataType="DATETIME"/>
    </changeSet>

    <changeSet id="03-add_cm_authentication_token_relative_path_and_token_expiry_columns" author="stefan.sanevski">
        <addColumn tableName="acm_authentication_token">
            <column name="cm_authentication_token_relative_path" type="CLOB"></column>
        </addColumn>
        <addColumn tableName="acm_authentication_token">
            <column name="cm_authentication_token_expiry_milliseconds" type="LONG"></column>
        </addColumn>
        <sql>UPDATE acm_authentication_token SET cm_authentication_token_expiry_milliseconds=259200000</sql>
    </changeSet>

    <changeSet id="04-add_cm_authentication_token_generic_path_column" author="denys.kotovyi">
        <addColumn tableName="acm_authentication_token">
            <column name="cm_authentication_token_generic_path" type="CLOB"></column>
        </addColumn>
    </changeSet>

</databaseChangeLog>
