Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Couple of questions from a liquibase noob

I'm evaluating liquibase for a project starting today.

Has anybody used it to create procedures, functions, basically all of the plsql stuff?

If not, is it possible to write embedded sql code in the xml files?

like image 262
Tom Avatar asked Oct 21 '09 19:10

Tom


2 Answers

There is a built-in createProcedure tag in liquibase for managing procedures. The best approach is usually to combine the or tags with runOnChange so liquibase will update your procedure when and only when you update the definition. That way you can do diffs between your changelog xml files over time and see how the procedure has changed.

Using the sqlFile tag to reference file per stored-proc is also popular, or, like you said, you can use the sql tag to inline custom sql.

like image 78
Nathan Voxland Avatar answered Sep 28 '22 12:09

Nathan Voxland


I've encountered issues with trying the use the sql tag for stored procedures, triggers, and functions, but in my case these were provably issues with the MySQL JDBC driver, and not Liquibase itself. The practice I've settled into is to use the sqlFile refactoring as Nathan suggests, then to control the SP/trigger/function code in the same project as the changelog, versioned in the source code system along with it. This lets you manage the SP/whatever code just like it was real source code.

Setting runOnChange="true" in the changeSet containing the sqlFile refactoring is essential. It is this switch (thank you, Nathan) that enables real source control of procedural database code.

like image 34
tlberglund Avatar answered Sep 28 '22 11:09

tlberglund