mysql - Liquibase preconditions: How do I check for a column being non-nullable? -


i have dbupgrade script want remove non-null constraint on column. want precondition check, , call alter table script when non-null.

the master.xml script progressive 1 keep adding scripts , entire thing runs everytime. after first time alter table script has run, not want run again.

couldn't find predefined precondition this, , not write sqlcheck either.

can done sqlcheck.

  • for mysql

    <preconditions onfail="mark_ran" onerror="continue">     <sqlcheck expectedresult="no">         select is_nullable          information_schema.columns          table_name='<table_name>'          , column_name='<column_name>'      </sqlcheck>    </preconditions> 
  • for oracle:

    <preconditions onfail="mark_ran" onerror="continue">     <sqlcheck expectedresult="n">         select nullable         user_tab_columns         table_name = '<table_name>'         , column_name = '<column_name>'     </sqlcheck> </preconditions> 
  • for sql server:

    <preconditions onfail="mark_ran" onerror="continue">     <sqlcheck expectedresult="0">       select is_nullable        sys.columns        object_id = object_id('<table_name>')         , name = '<column_name>'      </sqlcheck> </preconditions> 

Comments