I’m testing out liquibase for our dbs. we already have an existing dbs. I want to add our entire db into liquibase xml change log. I understand Liquibase would just work in existing db but I will only have change sets from that point. if I want to create a new db using changelog, I wont be able to without entire db schema and table create change sets in xml.
is there any way to do it ? like converting sql script to xml ?
I’m not 100% sure but what I know is if you are using Liquibase Pro, most of the objects (almost all) would get covered with generateChangelog. However, if you using community edition of Liquibase then generateChangelog will not extract :
for your PostgreSQL database. There could be more addition of objects to this list.
Thanks for your input. Could you please give me some advice what is the right way to use liquibase in my environment. I have a db in postgres and ms sql and there are couple of schemas in db. now when there is a change db, i write sql statement for both db and run them manually in each db. since i believe liquibase can update any db with xml changeset. I’m planning on using xml. Is this a good idea ?
Is there a way to keep changelog for each sql statement types of create, insert, alter, functions or changelogs for each schemas. what is the right way to do ?
Happy to know you are planning to use Liquibase in your project.
Using XML changelogs and changesets is a good idea. It has a lot of features which allows us to use different functions for DBs. Please follow this link for Liquibase best practices.
By “a way to keep changelog” if you mean to store them or keep them segregated, then you can have it in different folders.
For eg: You can create directory structure as follows -
- all your create changesets goes here
- all your insert changesets goes here
- all your update changesets goes here
- all your delete changesets goes here
To segregate your changesets for each schema you can similarly keep a directory structure of your own type. The way I have used in one of my projects is, I follow a format for naming a changeset file : <operation>_<schema>_<table_name>.xml
To execute it for different schemas please refer to my answer on this post. Link here : StackOverFlow Post
I hope I got your question right and could answer it.
Please let us know if you have any other queries or if you face any issues at the time of implementation.