modifySql: after each createTable, or only once?

Not clear on whether I should use after each statement in a changeset or just once at the end (with the understanding that it will apply to all relevant sql statements).  I’m assuming the former.  Before I bash around testing this out, I thought I’d check to see if someone could just quickly provide an answer.

Thanks!

Best,
Laird

The XSD should only allow one modifySql element per changeset, and it is applied to all SQL.

Note: It’s usually not the best idea to have multiple createTable changes per changeSet.  Liquibase attempts to run each the entire changeset plus the databasechangelog table update in a single transaction.  If there are multiple statements that are executed, if one fails the previous ones should be rolled back.  However, create table (and most ddl statements on most databases) are auto-committing, so if you have two createTable changes in one changeset and the second fails, liquibase will not run the changeSet as ran because it didn’t to completion, but the next time you execute your update it will fail because the first table already exists.  The general rule of thumb should be one change per changeSet unless they are not auto-committing statements.

Nathan

Good to know.  Thanks!

Postgres has transactional DDL I think. Haven’t used it but so I heard.

It does, but it’s the only database I know of that does, so it’s the exception that proves the one change per changeset rule :slight_smile:

Nathan

The more I think about, the more it becomes a questionmark why other DBMS’s haven’t implemented that. Seems like a natural thing to have.  ???

Seems like it.  I’d imagine it’s more difficult than one would think, especially managing transactions across multiple versions of a table.  Probably just being lazy, though :slight_smile:

Nathan

:slight_smile: