databaseChangeLog:
  - logicalFilePath: db-changelog-000479-add-translation-async-import-table.yaml
  - changeSet:
      author: appian
      id: 'tag-pre-000479'
      tagDatabase:
        tag: 'pre-000479'
  #----------------------------------------------------------------------------------------------------
  - changeSet:
      author: appian
      id: '000479.1.0'
      comment: Create ts_async_import table
      changes:
        - createTable:
            tableName: ts_async_import
            columns:
              - column:
                  name: id
                  type: ${longType}
                  autoIncrement: ${autoIncrement}
                  constraints:
                    nullable: false
                    primaryKey: true
              - column:
                  name: uuid
                  type: ${uuidType}
                  constraints:
                    nullable: false
                    unique: true
                    uniqueConstraintName: ts_async_import_uuid_uc
              - column:
                  name: ts_set_id
                  type: ${longType}
                  constraints:
                    nullable: false
              - column:
                  name: import_file_name
                  type: ${shortStringType}
                  constraints:
                    nullable: false
              - column:
                  name: status
                  type: ${byteType}
                  constraints:
                    nullable: false
              - column:
                  name: user_dismissed
                  type: ${booleanType}
                  constraints:
                    nullable: false
              - column:
                  name: error_message
                  type: ${mediumStringType}
                  constraints:
                    nullable: true
              - column:
                  name: created_ts
                  type: ${longType}
                  constraints:
                    nullable: true
              - column:
                  name: created_by
                  type: ${longType}
                  constraints:
                    nullable: true
              - column:
                  name: updated_ts
                  type: ${longType}
                  constraints:
                    nullable: true
              - column:
                  name: updated_by
                  type: ${longType}
                  constraints:
                    nullable: true

  - changeSet:
      id: '000479.1.1'
      comment: A sequence to provide primary key values for the translation async import table
      author: appian
      changes:
        preConditions:
          onFail: MARK_RAN
          changeLogPropertyDefined:
            property: createSequence
            value: true
        createSequence:
          sequenceName: ts_async_import_sq

  - changeSet:
      id: '000479.1.2'
      author: appian
      comment: Add FK for ts_async_import.created_by to usr.id
      addForeignKeyConstraint:
        constraintName: ts_async_import_created_by_fk
        baseTableName: ts_async_import
        baseColumnNames: created_by
        referencedTableName: usr
        referencedColumnNames: id

  - changeSet:
      id: '000479.1.3'
      author: appian
      comment: Add FK for ts_async_import.updated_by to usr.id
      addForeignKeyConstraint:
        constraintName: ts_async_import_updated_by_fk
        baseTableName: ts_async_import
        baseColumnNames: updated_by
        referencedTableName: usr
        referencedColumnNames: id

  - changeSet:
      id: '000479.1.4'
      author: appian
      comment: Add index on ts_async_import.created_by
      changes:
        createIndex:
          columns:
            - column:
                name: created_by
          indexName: ts_async_import_created_by_idx
          tableName: ts_async_import
          unique: false

  - changeSet:
      id: '000479.1.5'
      author: appian
      changes:
        comment: Add index on ts_async_import.updated_by
        createIndex:
          columns:
            - column:
                name: updated_by
          indexName: ts_async_import_updated_by_idx
          tableName: ts_async_import
          unique: false
