2
votes

I am trying to tag the database for future rollback using but getting below error:

Applying updates to the database. This may take a few minutes ... Unexpected error running Liquibase: Error parsing line 12 column 6 of ppsdb/ebidb_lb_upgrade_c43_sql_1.xml: cvc-complex-type.2.4.a: Invalid content was found starting with element 'sql'. One of '{"http://www.liquibase.org/xml/ns/dbchangelog/1.9":modifySql}' is expected.

Here is my changeSet file:

cat ebidb_lb_upgrade_c43_sql_1.xml

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<changeSet author="avnish_plsql_upgrade" id="1">
<tagDatabase tag="version_1.3"/>
<sql
        stripComments="false"
>
create table test (id number);
</sql>
</changeSet>
</databaseChangeLog>

When I am removing tagDatabase tag from file, I am not getting any error. It is only when I am adding this tag, I am getting above error. Please let me know, if I am missing any thing or making any mistake here.

2

2 Answers

2
votes

I had been facing the same issue. After searching for a while without any respite, I decided to take a look at the XSD and see how the elements were declared.

As per Liquibase documentation link the latest version of XSD is 3.1.

If you look at the 3.1 XSD, you can see that the tagDatabase and rest of the changeSet allowed elements are mutually exclusive (They are part of XSD:CHOICE)

<xsd:choice>
              <xsd:element ref="tagDatabase" maxOccurs="1"/>
              <xsd:group ref="changeSetChildren" minOccurs="0" maxOccurs="unbounded"/>
</xsd:choice>

To test my theory I created a new changeSet with just the tagDatabase element and could see that the migration was successful but obviously the second changSet was the only one tagged with the release Tag.

So for now, I will do a data update of the DATABASECHANGELOG table to update the tag column.

I hope liquibase guys comes out with a new XSD that fixes this issue.

-1
votes

I think the issue may be that you are using a very outdated xsd. In the header of the XML file, replace all instances of 1.9 with 3.6

Here is an example from one of my recent environments:

<databaseChangeLog 
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">