Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

4.4 KB
Raw Blame
## Adds transform_test: a test for one transform, replacing some of its input tables with fixture data and
## checking its output against expectations. The inputs and expectations are JSON documents validated by
## metabase-enterprise.transform-testing.schema.

databaseChangeLog:
  - changeSet:
      id: v65.2026-09-15T00:00:00
      author: ranquild
      comment: Add transform_test
      changes:
        - createTable:
            tableName: transform_test
            remarks: A test for a transform, with fixture inputs and expectations on its output
            columns:
              - column:
                  name: id
                  type: int
                  remarks: Unique ID
                  autoIncrement: true
                  constraints:
                    primaryKey: true
                    nullable: false
              - column:
                  name: entity_id
                  type: char(21)
                  remarks: NanoID for serdes
                  constraints:
                    nullable: false
                    unique: true
              - column:
                  name: transform_id
                  type: int
                  remarks: The transform under test
                  constraints:
                    nullable: false
              - column:
                  name: creator_id
                  type: int
                  remarks: The user who created the test suite
                  constraints:
                    nullable: false
              - column:
                  name: name
                  type: ${text.type}
                  remarks: The name of the test suite
                  constraints:
                    nullable: false
              - column:
                  name: description
                  type: ${text.type}
                  remarks: A description of the test suite
              - column:
                  name: inputs
                  type: ${text.type}
                  remarks: JSON array of the input tables replaced with fixture data
                  constraints:
                    nullable: false
              - column:
                  name: expectations
                  type: ${text.type}
                  remarks: JSON array of the expectations checked against the transform output
                  constraints:
                    nullable: false
              - column:
                  name: created_at
                  type: ${timestamp_type}
                  remarks: The timestamp this test suite was created
                  defaultValueComputed: current_timestamp
                  constraints:
                    nullable: false
              - column:
                  name: updated_at
                  type: ${timestamp_type}
                  remarks: The timestamp this test suite was last updated
                  defaultValueComputed: current_timestamp
                  constraints:
                    nullable: false

  - changeSet:
      id: v65.2026-09-15T00:00:01
      author: ranquild
      comment: Index transform_test.transform_id
      changes:
        - createIndex:
            tableName: transform_test
            indexName: idx_transform_test_transform_id
            columns:
              - column:
                  name: transform_id

  - changeSet:
      id: v65.2026-09-15T00:00:02
      author: ranquild
      comment: Add FK constraint on transform_test.transform_id
      changes:
        - addForeignKeyConstraint:
            baseTableName: transform_test
            baseColumnNames: transform_id
            referencedTableName: transform
            referencedColumnNames: id
            constraintName: fk_transform_test_transform_id
            onDelete: CASCADE

  - changeSet:
      id: v65.2026-09-15T00:00:03
      author: ranquild
      comment: Index transform_test.creator_id
      changes:
        - createIndex:
            tableName: transform_test
            indexName: idx_transform_test_creator_id
            columns:
              - column:
                  name: creator_id

  - changeSet:
      id: v65.2026-09-15T00:00:04
      author: ranquild
      comment: Add FK constraint on transform_test.creator_id
      changes:
        - addForeignKeyConstraint:
            baseTableName: transform_test
            baseColumnNames: creator_id
            referencedTableName: core_user
            referencedColumnNames: id
            constraintName: fk_transform_test_creator_id
            onDelete: CASCADE