databaseChangeLog:
  - logicalFilePath: db-changelog-000482-add-ssa-recently-viewed-table.yaml
  - changeSet:
      author: appian
      id: 'tag-pre-000482'
      tagDatabase:
        tag: 'pre-000482'
  - changeSet:
      id: '000482.1.0'
      author: appian
      changes:
        comment: Create ssa_recently_viewed table
        createTable:
          tableName: ssa_recently_viewed
          columns:
            - column:
                name: id
                type: ${longtype}
                autoIncrement: ${autoIncrement}
                constraints:
                  primaryKey: true
                  nullable: false
            - column:
                name: object_uuid
                type: ${uuidType}
                constraints:
                  nullable: false
                  unique: true
                  uniqueConstraintName: ssa_object_uuid_uc
            - column:
                name: object_type
                type: ${byteType}
                constraints:
                  nullable: false
            - column:
                name: user_id
                type: ${longType}
                constraints:
                  nullable: false
            - column:
                name: viewed_timestamp
                type: ${longType}
                constraints:
                  nullable: false
  - changeSet:
      id: '000482.1.1'
      author: appian
      comment: Add sequence to provide primary key values for the ssa_recently_viewed table
      changes:
        preConditions:
          onFail: MARK_RAN
          changeLogPropertyDefined:
            property: createSequence
            value: true
        createSequence:
          sequenceName: ssa_recently_viewed_sq
  - changeSet:
      id: '000482.1.2'
      author: appian
      comment: Add FK for ssa_recently_viewed.user_id to usr.id
      addForeignKeyConstraint:
        constraintName: ssa_recently_viewed_user_id_fk
        baseTableName: ssa_recently_viewed
        baseColumnNames: user_id
        referencedTableName: usr
        referencedColumnNames: id
  - changeSet:
      id: '000482.1.3'
      author: appian
      comment: Add indexes on ssa_recently_viewed.user_id
      changes:
        - createIndex:
            tableName: ssa_recently_viewed
            columns:
              - column:
                  name: user_id
            indexName: ssa_recent_viewed_usr_id_idx
