I have a db upgrade script to remove the non-null constraint on a column. I want to do a precondition check, and call ALTER TABLE
only when it is non-null.
The master.xml script is a progressive one where I keep adding scripts and the entire thing runs everytime. After the first time my Alter Table script has run, I do not want it to be run again.
Couldn't find a predefined precondition for this, and could not write an sqlcheck either.
Can be done with sqlCheck.
For MySql
For Oracle:
For SQL Server:
Revising my answer. Liquibase supports an add not null constraint operation as follows:
This automatically handles columns that are null, in my example populating them with the text string "NULL".
I don't think this changeset requires a pre-condition. Worst case you'd re-apply the existing column constraint, once. Liquibase tracks all changsets and ensures they are not executed again.