views:

263

answers:

1

Hi, Im using the sqlFile to include an sql script that creates tables using oracle specific commands (NOCACHE, NO PARALLEL, stuff like that). My master.xml file includes all sql scripts and executes them. However, when it detects a tag, it fails and prints this error message.

C:\update.bat master.xml
Migration Failed: cvc-complex-type.2.4.a: Invalid content was found starting with element 'sqlFile'. 
One of '{
"http://www.liquibase.org/xml/ns/dbchangelog/1.9":preConditions,
"http://www.liquibase.org/xml/ns/dbchangelog/1.9":property,
"http://www.liquibase.org/xml/ns/dbchangelog/1.9":changeSet, 
"http://www.liquibase.org/xml/ns/dbchangelog/1.9":include,
"http://www.liquibase.org/xml/ns/dbchangelog/1.9":includeAll
}' is expected.

My master.xml is quite simple

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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"&gt;

    <sqlFile path="createUsers.sql"/>
</databaseChangeLog>

Any thoughts will be greatly appreciated. Thanks in advance.

+2  A: 

I know nothing about liquibase, but that's the beauty of XML Schema: by reading the XSD we can infer what the system expects when we provide it a databaseChangeLog.

If you look in the XSD, you can see that effectively a <databaseChagneLog> element should include of the element listed (<preCondition>, <property>, <changeSet> etc... as reported in the error message.

It appears (from reading the XSD) that the <sqlFile> element should be included in a <changeSet>.

So maybe you just need:

... Header + databaseChangelog and its Namespace =as previously
...
   <changeSet>
       <sqlFile path="createUsers.sql"/>
   </changeSet>
</databaseChangeLog>

But as said, I know nothing of the underlying semantics, or even the general purpose of liquibase. You may therefore refer to liquibase documentation to see what else you may need to declare etc. (for example the XSD allows many other elements such as validCheckSum, preContidtion etc. to be optionally included)

mjv
thanks. Reading the xsd is now on my "things to do when sh*t happens" list.
Tom
Note that you will need an "id" and "author" attribute in the changeSet tag. Like: <changeSet id="1" author="tom">
Nathan Voxland