databaseChangeLog:
  - logicalFilePath: db-changelog-000556-add-ad-hoc-events-table.yaml
  - changeSet:
      author: appian
      id: 'tag-pre-000556'
      tagDatabase:
        tag: 'pre-000556'

  - changeSet:
      id: '000556.1.0'
      author: appian
      comment: Create mining_prc_adhoc_event table
      changes:
        - createTable:
            tableName: mining_prc_adhoc_event
            columns:
              - column:
                  name: id
                  type: ${longtype}
                  autoIncrement: ${autoIncrement}
                  constraints:
                    primaryKey: true
                    nullable: false
              - column:
                  name: mining_process_id
                  type: ${longtype}
                  constraints:
                    nullable: false
              - column:
                  name: mining_process_field_id
                  type: ${longType}
                  constraints:
                    nullable: false
              - column:
                  name: is_dismissed
                  type: ${booleanType}
                  constraints:
                    nullable: false
              - column:
                  name: event_name
                  type: ${mediumStringType}
                  constraints:
                    nullable: false
  - changeSet:
      id: '000556.1.1'
      author: appian
      comment: Create sequence for primary key
      changes:
        - preConditions:
            onFail: MARK_RAN
            changeLogPropertyDefined:
              property: createSequence
              value: true
        - createSequence:
            sequenceName: mining_prc_adhoc_event_sq
  - changeSet:
      id: '000556.1.2'
      author: appian
      comment: Add FK for mining_prc_adhoc_event.mining_process_id to mining_process.id
      addForeignKeyConstraint:
        constraintName: prc_adhoc_event_proc_id_fk
        baseTableName: mining_prc_adhoc_event
        baseColumnNames: mining_process_id
        referencedTableName: mining_process
        referencedColumnNames: id
  - changeSet:
      id: '000556.1.3'
      author: appian
      comment: Add FK for mining_prc_adhoc_event.mining_process_field_id to mining_process_field.id
      addForeignKeyConstraint:
        constraintName: process_fld_adhoc_event_id_fk
        baseTableName: mining_prc_adhoc_event
        baseColumnNames: mining_process_field_id
        referencedTableName: mining_process_field
        referencedColumnNames: id
        onDelete: CASCADE
  - changeSet:
      id: '000556.1.4'
      author: appian
      comment: Add index on mining_prc_adhoc_event.mining_process_id
      changes:
        - createIndex:
            tableName: mining_prc_adhoc_event
            columns:
              - column:
                  name: mining_process_id
            indexName: prc_adhoc_event_proc_id_idx
  - changeSet:
      id: '000556.1.5'
      author: appian
      comment: Add index on mining_prc_adhoc_event.mining_process_field_id
      changes:
        - createIndex:
            tableName: mining_prc_adhoc_event
            columns:
              - column:
                  name: mining_process_field_id
            indexName: process_fld_adhoc_event_id_idx

