For the complete documentation index, see llms.txt. This page is also available as Markdown.

Get Started with Changelogs

Learn how to define changelogs for SQL and MongoDB in Harness Database DevOps.

Harness Database DevOps supports changelogs in various formats to manage schema changes across environments. Below are examples of SQL and MongoDB changelogs to help you get started quickly.

Example changelogs

databaseChangeLog:
  - changeSet:
      id: product-table-v2
      author: john-doe
      labels: products-api 
      comment: Creating product table for REST API
      changes:
        - createTable:
            tableName: product
            columns:
              - column:
                  name: id
                  type: SERIAL
                  constraints:
                    primaryKey: true
              - column:
                  name: name
                  type: VARCHAR(100)
                  constraints:
                    nullable: false
              - column:
                  name: price
                  type: NUMERIC(10,2)
                  defaultValue: 0.00
                  constraints:
                    nullable: false
      rollback:
        - dropTable:
            tableName: product
  - changeSet:
      id: product-table-indexes-v2
      author: john-doe
      labels: products-api
      comment: Adding indexes for the products table
      changes:
        - createIndex:
            tableName: product
            columns:
              - column:
                  name: name
            indexName: idx_products_name
      rollback:
        - dropIndex:
            indexName: idx_products_name
            tableName: product
  - changeSet:
      id: product-sample-data-initial
      author: john-doe
      labels: products-api-v2
      comment: Inserting initial sample data for non-production environments
      changes:
        - insert:
            tableName: product
            columns:
              - column:
                  name: name
                  value: "Wireless Bluetooth Headphones"
              - column:
                  name: price
                  value: 89.99
        - insert:
            tableName: product
            columns:
              - column:
                  name: name
                  value: "USB-C Charging Cable"
              - column:
                  name: price
                  value: 15.99
      rollback:
        - delete:
            tableName: product
            where: name in ('Wireless Bluetooth Headphones', 'USB-C Charging Cable')
  - changeSet:
      id: product-sample-data-accessories
      author: john-doe
      labels: products-api
      comment: Inserting accessories sample data for non-production environments
      changes:
        - insert:
            tableName: product
            columns:
              - column:
                  name: name
                  value: "Wireless Mouse Pad"
              - column:
                  name: price
                  value: 12.50
        - insert:
            tableName: product
            columns:
              - column:
                  name: name
                  value: "Ergonomic Laptop Stand"
              - column:
                  name: price
                  value: 65.99
      rollback:
        - delete:
            tableName: product
            where: name in ('Wireless Mouse Pad', 'Ergonomic Laptop Stand')

Next steps

Last updated

Was this helpful?