databaseChangeLog:
  - logicalFilePath: db-changelog-000570-add-mining-insight-metric-table.yaml
  - changeSet:
      author: appian
      id: tag-pre-000570
      tagDatabase:
        tag: 'pre-000570'
  - changeSet:
      id: '000570.1.0'
      author: appian
      comment: Create mining_insight_metric table
      changes:
        - createTable:
            tableName: mining_insight_metric
            columns:
              - column:
                  name: id
                  type: ${longType}
                  autoIncrement: ${autoIncrement}
                  constraints:
                    nullable: false
                    primaryKey: true
              - column:
                  name: mining_insight_id
                  type: ${longType}
                  constraints:
                    nullable: false
              - column:
                  name: metric_key
                  type: ${mediumStringType}
                  constraints:
                    nullable: false
              - column:
                  name: metric_value
                  type: ${doubleType}
                  constraints:
                    nullable: false
  - changeSet:
      author: appian
      id: '000570.2.0'
      comment: Create index for mining_insight_metric.mining_insight_id
      changes:
        - createIndex:
            indexName: mining_insight_metric_miid_idx
            tableName: mining_insight_metric
            columns:
              - column:
                  name: mining_insight_id
  - changeSet:
      author: appian
      id: '000570.3.0'
      comment: Add fk for base table mining_insight_metric
      changes:
        - addForeignKeyConstraint:
            constraintName: mining_insight_metric_miid_fk
            baseTableName: mining_insight_metric
            baseColumnNames: mining_insight_id
            referencedTableName: mining_insight
            referencedColumnNames: id
            onDelete: CASCADE
  - changeSet:
      author: appian
      id: '000570.4.0'
      comment: Create sequence to provide primary key value for insight metric
      changes:
        - preConditions:
            onFail: MARK_RAN
            changeLogPropertyDefined:
              property: createSequence
              value: true
        - createSequence:
            sequenceName: mining_insight_metric_sq
