<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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-2.0.xsd"
  logicalFilePath="db-changelog-000067-web-api-history.xml">

  <changeSet author="appian" id="tag-000066">
    <tagDatabase tag="000066"/>
  </changeSet>

  <changeSet author="appian" id="web-api-history.1.0">
    <comment>Add web_api_history table</comment>
    <createTable tableName="web_api_history">
      <column name="id" type="${longType}" autoIncrement="${autoIncrement}">
        <constraints nullable="false" primaryKey="true"/>
      </column>
      <column name="web_api_id" type="${longType}">
        <constraints nullable="false"/>
      </column>
      <column name="uuid" type="${uuidType}">
        <constraints nullable="false"/>
      </column>
      <column name="name" type="${shortStringType}">
        <constraints nullable="false"/>
      </column>
      <column name="description" type="${mediumStringType}" />
      <column name="expression" type="${mediumStringType}" />
      <column name="url_alias" type="${shortStringType}" >
        <constraints nullable="false"/>
      </column>
      <column name="http_method" type="${shortStringType}">
        <constraints nullable="false"/>
      </column>
      <column name="created_ts" type="${longType}">
        <constraints nullable="false"/>
      </column>
      <column name="created_by" type="${longType}">
        <constraints nullable="false"/>
      </column>
      <column name="updated_ts" type="${longType}">
        <constraints nullable="false"/>
      </column>
      <column name="updated_by" type="${longType}">
        <constraints nullable="false"/>
      </column>
    </createTable>
    <modifySql dbms="mysql">
      <append value="${mysqlEngineSql}"/>
    </modifySql>
  </changeSet>
  <changeSet author="appian" id="web-api-history.1.1">
    <preConditions onFail="MARK_RAN">
      <changeLogPropertyDefined property="createSequence" value="true"/>
    </preConditions>
    <createSequence sequenceName="web_api_history_sq"/>
  </changeSet>
  <changeSet author="appian" id="web-api-history.1.2">
    <comment>Create an index for the column web_api_history.web_api_id</comment>
    <createIndex indexName="wahstry_waid_idx" tableName="web_api_history" unique="false">
      <column name="web_api_id"/>
    </createIndex>
  </changeSet>
  <changeSet author="appian" id="web-api-history.1.3">
    <comment>Create an index for the column web_api_history.updated_ts</comment>
    <createIndex indexName="wahstry_uptswaid_idx" tableName="web_api_history" unique="true">
      <column name="updated_ts"/>
      <column name="web_api_id"/>
    </createIndex>
  </changeSet>
</databaseChangeLog>
