changelogs in JSON Format

Liquibase supports JSON as a format for storing your changelog files.

Uses

When using a JSON-based changelog file, you need to choose one of the following ways to audit your database and execute changes:

  • Pass it as an argument in the command line during runtime:
liquibase --changeLogFile=changelog.json update
  • Specify it in your liquibase.properties file:
changeLogFile: ../changelog.json

You can also include other related properties in the liquibase.properties file, such as the classpath, which specifies the directories and .jar files to search for changelog files and custom extension classes. If you have multiple files, they can be separated with ; on Windows or : on Linux or MacOS. Also, it is recommended to use a relative path:

classpath: ../path/to/liquibase-mongodb-4.2.2.jar;../path/to/mongo-java-driver-3.12.7.jar

Note: For more information, see Creating and configuring a liquibase.properties file.

Example

        {
            "databaseChangeLog": [
              {
                "preConditions": [
                  {
                    "runningAs": {
                      "username": "liquibase"
                    }
                  }
                ]
              },
              {
                "changeSet": {
                  "id": "1",
                  "author": "nvoxland",
                  "changes": [
                    {
                      "createTable": {
                        "tableName": "person",
                        "columns": [
                          {
                            "column": {
                              "name": "id",
                              "type": "int",
                              "autoIncrement": true,
                              "constraints": {
                                "primaryKey": true,
                                "nullable": false
                              },
                              
                            }
                          },
                          {
                            "column": {
                              "name": "firstname",
                              "type": "varchar(50)"
                            }
                          },
                          {
                            "column": {
                              "name": "lastname",
                              "type": "varchar(50)",
                              "constraints": {
                                "nullable": false
                              },
                              
                            }
                          },
                          {
                            "column": {
                              "name": "state",
                              "type": "char(2)"
                            }
                          }
                        ]
                      }
                    }
                  ]
                }
              },
              {
                "changeSet": {
                  "id": "2",
                  "author": "nvoxland",
                  "changes": [
                    {
                      "addColumn": {
                        "tableName": "person",
                        "columns": [
                          {
                            "column": {
                              "name": "username",
                              "type": "varchar(8)"
                            }
                          }
                        ]
                      }
                    }
                  ]
                }
              },
              {
                "changeSet": {
                  "id": "3",
                  "author": "nvoxland",
                  "changes": [
                    {
                      "addLookupTable": {
                        "existingTableName": "person",
                        "existingColumnName": "state",
                        "newTableName": "state",
                        "newColumnName": "id",
                        "newColumnDataType": "char(2)",
                        
                      }
                    }
                  ]
                }
              }
            ]
          }