1

in a DevOps (CI/CD) scenario, when Liquibase is triggered by a specific step of a pipeline, is a good practice that Liquibase drops all application ( microservice ) DB tables and recreate all DDL/DML using changesets (only for test and pre-production environment) ?\

If it is, why?

thanks

cyberdemon
  • 43
  • 2
  • 10
  • 2
    No, it should always go only forward, so apply all to the existing database. I wouldn't do drop/recreate. That could be tested with integration tests not on real environment. Or it could be tested in ci/cd against empty databases (you can use testcontainers). – bilak Nov 03 '22 at 16:18

1 Answers1

1

Liquibase is designed to maintain database model consistency between all environments. And when you drop database in one of them you break that consistency as you wouldn't want to drop production database as well. Check out Roll Back the Database or Fix Forward? article

If you need to drop some table, you should write additional <dropTable> changeSet.

If you need to test initial application deployment on an empty database, you can always use containers, as suggested by @bilak in the comments.

htshame
  • 6,599
  • 5
  • 36
  • 56
  • Actually in test environment every time a CI is triggered, Liquibase drops all and recreate all DDL and DML using changesets. In this way i remove all useless data written for test purpose or tables created but not accepted in superior env., ensuring that i always have a clean DB. Do you thing is a bad way to operate? – cyberdemon Nov 08 '22 at 10:54