<sql> fails after XML changeset

I’ve just taken over an old project. It is using liquibase 3.5.3 against Oracle Enterprise 19c.

There are <sql> tags all over the place, even where there is a specific XML tag to do the job!

However, a very common pattern is this:

<changeSet ...>
  <createTable tableName="XX" ...

</changeSet>

<changeSet ...>
  <sql>
    grant select on XX to some_user
  </sql>
</changeSet>

If I run a dropAll and then update, it will always fail on the grant, complaining that the table does not exist. If I then run update again, it will succeed. Because this happens throughout the (very large) changelog, I have to run update many times.

As a test, I have changed some <sql> tags that were failing into the equivalent XML tags and they then work. But I cannot change every <sql> tag since there are some things that cannot be done that way. However, this seems to confirm that it is caused by an <sql> tag operating on something that was just created by a “regular” XML tag. I have tested this with index rebuilds, datatype changes and null constraints. It doesn’t matter whether the <sql> is in the same changeset or a different one.

I am also told by a colleague, that this does not happen when running the same changelog against a different schema. I can’t test that just at the moment because I don’t have loads of spare schemas around.

Before I spend a lot of time creating a test rig, does this sound familiar to anyone?

If my colleague is correct, it is probably a setting on the schema. But what to look for?! If he is mistaken, then is it a known bug in liquibase 3.5.3?

I am using Liquibase 3.10.2. I created this exact scenario in my changelog:

  • xml format
  • changeset 1: xml createTable change-type
  • changeset 2: custom sql grant statement on new table

I was unable to recreate your error. As a first step I would suggest upgrading your Liquibase version.

I was also unable to reproduce it in a clean installation.

Unfortunately, I can’t upgrade at the moment, so I feel a retry script hack coming on! I will try an upgrade as soon as I can arrange it.