Quantcast
Channel: Liquibase Forums
Viewing all articles
Browse latest Browse all 2993

How do I get Liquibase to print out the SQL it generated?

$
0
0

Hi,


I’m using Gradle 2.7, the Liquibase 1.1.1 plugin and attempting to run my changeset on an Apache Derby (v. 10.12.1.1) in-memory database.  Running the following changeSet fails immediately on the first changeSet …


[code]

        <changeSet author="my" id="add_my_project_address">

                <createTable tableName="my_project_address">

            <column defaultValue="" name="id" type="VARCHAR(32)">

                <constraints nullable="false" primaryKey="true"/>

            </column>

            <column defaultValue="" name="address" type="VARCHAR(500)">

                <constraints nullable="true"/>

            </column>

            <column defaultValue="" name="city" type="VARCHAR(100)">

                <constraints nullable="true"/>

            </column>

            <column defaultValue="" name="state" type="VARCHAR(10)">

                <constraints nullable="true"/>

            </column>

            <column defaultValue="" name="zip" type="VARCHAR(10)">

                <constraints nullable="true"/>

            </column>

            <column defaultValue="" name="lattitude" type="INT UNSIGNED">

                <constraints nullable="true"/>

            </column>

            <column defaultValue="" name="longitude" type="INT UNSIGNED">

                <constraints nullable="true"/>

            </column>

            <column defaultValue="" name="email" type="VARCHAR(200)">

                <constraints nullable="true"/>

            </column>

            <column defaultValue="" name="phone" type="VARCHAR(32)">

                <constraints nullable="true"/>

            </column>

            <column defaultValue="" name="phone_type" type="VARCHAR(10)">

                <constraints nullable="true"/>

            </column>

                </createTable>

        </changeSet>

[/code]


How can I configure Liquibase to output the SQL generated?  Here is how I have set up the plugin …


[code]

liquibase {

  activities {

    main {

      File propsFile = new File("${project.rootDir}/src/main/environment/${environment}/liquibase.properties")

      Properties properties = new Properties()

      properties.load(new FileInputStream(propsFile))

      changeLogFile 'src/main/resources/db.changelog-master.xml'

      url properties['url']

      username properties['username']

      password properties['password']

    }

    test {

      File propsFile = new File(liquibasePropertiesFile)

      Properties properties = new Properties()

      properties.load(new FileInputStream(propsFile))

      changeLogFile 'src/main/resources/db.changelog-master.xml'

        url 'jdbc:derby:memory:test-jpa;create=true'

        username 'sa'

    }

    runList = 'main,test'

  }

}

[/code]


For what its worth, this is all Liquibase tells me when the above is run …


[code]

SEVERE 10/27/15 4:02 PM: liquibase: src/main/resources/db.changelog-master.xml: src/main/resources/db.changelog-1.0.xml::add_my_project_address::my: Change Set src/main/resources/db.changelog-1.0.xml::add_my_project_address::my failed.  Error: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "," at line 1, column 224.

liquibase.exception.DatabaseException: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "," at line 1, column 224.

at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:316)

at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)

at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:122)

at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1227)

at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1210)

at liquibase.changelog.ChangeSet.execute(ChangeSet.java:550)

at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:43)

at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73)

at liquibase.Liquibase.update(Liquibase.java:200)

at liquibase.integration.commandline.Main.doMigration(Main.java:1044)

at liquibase.integration.commandline.Main.run(Main.java:175)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)

at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)

at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:43)

at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:88)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)

at org.liquibase.gradle.LiquibaseTask.runLiquibase(LiquibaseTask.groovy:97)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

[/code]


Viewing all articles
Browse latest Browse all 2993

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>