databaseChangeLog:
  - logicalFilePath: db-changelog-001000-delete-join-indices-job-qrtz.yaml
  - changeSet:
      author: appian
      id: tag-pre-001000
      tagDatabase:
        tag: 'pre-001000'

  # AN-272433 This migration deletes the ADS join indices job and associated triggers as it is no longer
  # necessary with ADS 2.0.

  # The following tables (QRTZ_BLOB_TRIGGERS, QRTZ_CRON_TRIGGERS, QRTZ_SIMPLE_TRIGGERS, QRTZ_SIMPROP_TRIGGERS) have a foreign key
  # constraint on QRTZ_TRIGGERS so these rows must be deleted first.
  - changeSet:
      author: appian
      id: '001000.1.0'
      comment: Remove ads join indices rows from QRTZ_BLOB_TRIGGERS
      changes:
        - delete:
            tableName: QRTZ_BLOB_TRIGGERS
            where: TRIGGER_NAME='record_synchronize_ads_join_indices'

  - changeSet:
      author: appian
      id: '001000.1.1'
      comment: Remove ads join indices rows from QRTZ_CRON_TRIGGERS
      changes:
        - delete:
            tableName: QRTZ_CRON_TRIGGERS
            where: TRIGGER_NAME='record_synchronize_ads_join_indices'

  - changeSet:
      author: appian
      id: '001000.1.2'
      comment: Remove ads join indices rows from QRTZ_SIMPLE_TRIGGERS
      changes:
        - delete:
            tableName: QRTZ_SIMPLE_TRIGGERS
            where: TRIGGER_NAME='record_synchronize_ads_join_indices'

  - changeSet:
      author: appian
      id: '001000.1.3'
      comment: Remove ads join indices rows from QRTZ_SIMPROP_TRIGGERS
      changes:
        - delete:
            tableName: QRTZ_SIMPROP_TRIGGERS
            where: TRIGGER_NAME='record_synchronize_ads_join_indices'

  # QRTZ_TRIGGERS has a foreign key constraint on QRTZ_JOB_DETAILS so its rows must be deleted first.
  - changeSet:
      author: appian
      id: '001000.1.4'
      comment: Remove ads join indices rows from QRTZ_TRIGGERS
      changes:
        - delete:
            tableName: QRTZ_TRIGGERS
            where: TRIGGER_NAME='record_synchronize_ads_join_indices'

  - changeSet:
      author: appian
      id: '001000.1.5'
      comment: Remove ads join indices rows from QRTZ_JOB_DETAILS
      changes:
        - delete:
            tableName: QRTZ_JOB_DETAILS
            where: JOB_NAME='record_synchronize_ads_join_indices'

  - changeSet:
      author: appian
      id: '001000.1.6'
      comment: Remove ads join indices rows from QRTZ_FIRED_TRIGGERS
      changes:
        - delete:
            tableName: QRTZ_FIRED_TRIGGERS
            where: TRIGGER_NAME='record_synchronize_ads_join_indices'
