How to specify rollback in JSON changelog file?

  1. {
  2.     "databaseChangeLog":[
  3.         {
  4.             "changeSet":{
  5.                 "id":"1",
  6.                 "author":"someone",
  7.                 "changes":[
  8.                     {
  9.                         "createTable":{
  10.                             "tableName":"USER",
  11.                             "columns":[
  12.                                 {
  13.                                     "column":{
  14.                                         "name":"NAME",
  15.                                         "type":"VARCHAR(255)"
  16.                                     }
  17.                                 }
  18.                             ]
  19.                         }
  20.                     },
  21.                     {
  22.                         "loadData":{
  23.                             "file":"db/changelogs/1.0.0 initialization/data/user.csv",
  24.                             "tableName":"USER"
  25.                         }
  26.                     }
  27.                 ]
  28.             }
  29.         }
  30.     ]
  31. }

I want to just drop table with all its content.
I've tried different approaches, but no rollback is triggered

You should be able to include a rollback block after your changes block:


  1. {
  2.     "databaseChangeLog": [
  3.         {
  4.             "changeSet": {
  5.                 "id": "included_json",
  6.                 "author": "nvoxland",
  7.                 "changes": [
  8.                     {
  9.                         "createTable": {
  10.                             "tableName": "included_json",
  11.                             "columns": [
  12.                                 {
  13.                                     "column": {
  14.                                         "name": "id",
  15.                                         "type": "int"
  16.                                     }
  17.                                 }
  18.                             ]
  19.                         }
  20.                     }
  21.                 ],
  22.                 "rollback": [
  23.                     {
  24.                         "sql": {
  25.                             "sql": "drop table multiRollback1;"
  26.                         }
  27.                     }
  28.                 ]
  29.             }

  30.         }
  31.     ]
  32. }

nvoxland, thank you for your response. I have not thought value of rollback attribute should be an arrayThank you!

Glad you got it. It is maybe a bit strange to be an array,but you can define multiple rollback blocks.


Good to hear liquibase has been helpful. I’ve been able to switch over to full time liquibase in the last couple weeks so now I’ll actually have time for the documentation which will help a lot :slight_smile:


Nathan