On the page sqlFile | Liquibase Docs is said: “Currently, there is no SQL Example for the Change Type because you can just put SQL directly into a SQL formatted changelog.”
My question is: is it in general not possible to put external sql files into a sql-changelog or there are only no example available? It would be very sad if in a sql-changelog no external files could be included, because the other formats (xml/yaml/jason) are not alternatives to sql, since you need to learn and introduce new commands, which dont have any added value to any organisation.
Thanks for the answer!
Hi @kirilb Thanks for the question. There is not a way to reference another file in a sql-changelog file. That is why there is no example. What you can do is setup a simple xml/json,yaml file as your main file that references each and every sql file that you want referenced. sql files are meant for sql. What are you trying to accomplish by using .sql instead of .xml , .json, or .yaml in the filename? We can most likely come up with a solution to your issue.
Hi MikeOlivas, thanks for the reply!
Imagine the case where for a db-release hundreds of db objects are planned, e.g. new tables, changes in views, packages and so on. How to store all this information in a single sql file? First it will be error prone, second it will be confusing and unclear and third usually when changes are done in a sql IDE and the exported as single files for each object.
What is the disadvantage of xml/json,yaml? It requires the introduction of additional logic and with that also is extremely error prone. How would you add each of those external sql-files. It is possible only manually. While adding manually external sql files e.g. in a sqlplus batch does not require additional lines/logic/code, this is not the case with xml/json,yaml.
Those formats look good only if you have few objects. For me the only option to use Liquibase at all is to be able to put in a sql changelog external sql files. This can be automated, but even done manually is no brainer.
@kirilb I think your point is that it is a pain to have to use an xml/yamll/json wrapper if you want to use the sqlFile method of including a file. I would agree.
I would suggest to use liquibase formatted sql and put the sql statements directly in the file, this will eliminate the need to the xml/yaml/json wrapper.
Just add the required Liquibase markups in your IDE when you export the files.