databaseChangeLog:
  - logicalFilePath: db-changelog-000582-rc-plan-data-model.yaml
  - changeSet:
      author: appian
      id: tag-pre-000582
      tagDatabase:
        tag: 'pre-000582'
  - changeSet:
      author: appian
      id: '000582.0.0'
      comment: Create req_capture_entity table
      changes:
        - createTable:
            tableName: req_capture_entity
            columns:
              - column:
                  name: id
                  type: ${longtype}
                  autoIncrement: ${autoIncrement}
                  constraints:
                    nullable: false
                    primaryKey: true
              - column:
                  name: requirements_capture_id
                  type: ${longtype}
                  constraints:
                    nullable: false
              - column:
                  name: name
                  type: ${shortStringType}
                  constraints:
                    nullable: false
  - changeSet:
      author: appian
      id: '000582.0.1'
      comment: Add FK constraint on requirements_capture_id to point to requirements_capture.id
      changes:
        - addForeignKeyConstraint:
            constraintName: req_capture_entity_rcid_fk
            baseTableName: req_capture_entity
            baseColumnNames: requirements_capture_id
            referencedTableName: requirements_capture
            referencedColumnNames: id
            onDelete: CASCADE
  - changeSet:
      author: appian
      id: '000582.0.2'
      comment: Unique key constraint on requirements_capture_id, name
      changes:
        - addUniqueConstraint:
            tableName: req_capture_entity
            columnNames: requirements_capture_id, name
            constraintName: req_capture_entity_uc
  - changeSet:
      author: appian
      id: '000582.0.3'
      comment: Create a sequence to provide primary key values for the req_capture_entity table
      preConditions:
        - onFail: MARK_RAN
        - changeLogPropertyDefined:
            property: createSequence
            value: true
      changes:
        - createSequence:
            sequenceName: req_capture_entity_sq
  - changeSet:
      author: appian
      id: '000582.0.4'
      comment: Create req_cap_entity_attribute table
      changes:
        - createTable:
            tableName: req_cap_entity_attribute
            columns:
              - column:
                  name: id
                  type: ${longtype}
                  autoIncrement: ${autoIncrement}
                  constraints:
                    nullable: false
                    primaryKey: true
              - column:
                  name: req_capture_entity_id
                  type: ${longtype}
                  constraints:
                    nullable: false
              - column:
                  name: name
                  type: ${shortStringType}
                  constraints:
                    nullable: false
              - column:
                  name: attribute_type
                  type: ${byteType}
                  defaultValue: 0
                  constraints:
                    nullable: false
              - column:
                  name: is_primary_key
                  type: ${booleanType}
                  defaultValueBoolean: false
                  constraints:
                    nullable: false
              - column:
                  name: is_unique
                  type: ${booleanType}
                  defaultValueBoolean: false
                  constraints:
                    nullable: false
  - changeSet:
      author: appian
      id: '000582.0.5'
      comment: Add FK constraint on req_capture_entity_id to point to req_capture_entity.id
      changes:
        - addForeignKeyConstraint:
            constraintName: req_cap_entity_attr_rceid_fk
            baseTableName: req_cap_entity_attribute
            baseColumnNames: req_capture_entity_id
            referencedTableName: req_capture_entity
            referencedColumnNames: id
            onDelete: CASCADE
  - changeSet:
      author: appian
      id: '000582.0.6'
      comment: Unique key constraint on req_capture_entity_id, name
      changes:
        - addUniqueConstraint:
            tableName: req_cap_entity_attribute
            columnNames: req_capture_entity_id, name
            constraintName: req_cap_attribute_id_name_uc
  - changeSet:
      author: appian
      id: '000582.0.7'
      comment: Create a sequence to provide primary key values for the req_cap_entity_attribute table
      preConditions:
        - onFail: MARK_RAN
        - changeLogPropertyDefined:
            property: createSequence
            value: true
      changes:
        - createSequence:
            sequenceName: req_cap_entity_attribute_sq
  - changeSet:
      author: appian
      id: '000582.0.8'
      comment: Create req_cap_entity_relationship table
      changes:
        - createTable:
            tableName: req_cap_entity_relationship
            columns:
              - column:
                  name: id
                  type: ${longtype}
                  autoIncrement: ${autoIncrement}
                  constraints:
                    nullable: false
                    primaryKey: true
              - column:
                  name: source_attribute_id
                  type: ${longtype}
                  constraints:
                    nullable: false
              - column:
                  name: target_attribute_id
                  type: ${longtype}
                  constraints:
                    nullable: false
              - column:
                  name: relationship_type
                  type: ${byteType}
                  defaultValue: 0
                  constraints:
                    nullable: false
  - changeSet:
      author: appian
      id: '000582.0.9'
      comment: Add FK constraint on source_attribute_id to point to req_cap_entity_attribute.id
      changes:
        - addForeignKeyConstraint:
            constraintName: rc_entity_relationship_said_fk
            baseTableName: req_cap_entity_relationship
            baseColumnNames: source_attribute_id
            referencedTableName: req_cap_entity_attribute
            referencedColumnNames: id
            onDelete: CASCADE
  - changeSet:
      author: appian
      id: '000582.0.10'
      comment: Add FK constraint on target_attribute_id to point to req_cap_entity_attribute.id
      changes:
        - addForeignKeyConstraint:
            constraintName: rc_entity_relationship_taid_fk
            baseTableName: req_cap_entity_relationship
            baseColumnNames: target_attribute_id
            referencedTableName: req_cap_entity_attribute
            referencedColumnNames: id
  - changeSet:
      author: appian
      id: '000582.0.11'
      comment: Unique key constraint on source_attribute_id, target_attribute_id
      changes:
        - addUniqueConstraint:
            tableName: req_cap_entity_relationship
            columnNames: source_attribute_id, target_attribute_id
            constraintName: rcer_source_target_attr_uc
  - changeSet:
      author: appian
      id: '000582.0.12'
      comment: Create a sequence to provide primary key values for the req_cap_entity_relationship table
      preConditions:
        - onFail: MARK_RAN
        - changeLogPropertyDefined:
            property: createSequence
            value: true
      changes:
        - createSequence:
            sequenceName: req_cap_entity_relationship_sq
