New Topic: [LB2-b3] changelog file with condition and sequence definition on MySQL

View: New views
1 Messages — Rating Filter:   Alert me  

New Topic: [LB2-b3] changelog file with condition and sequence definition on MySQL

by LiquiBase Community Forum :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

A new topic, '[LB2-b3] changelog file with condition and sequence definition on MySQL', has been made on a board you are watching.

You can see it at
http://liquibase.org/forum/index.php?topic=157.new#new

The text of the topic is shown below:

Hi,

Trying the Liquibase B3 (from subversion, revision 1157) I have the following problem. The changelog includes a changeset to create a sequence on Oracle and is marked with a pre-condition which checks the database type. When the file is executed against a MySQL database and the SQL is not executed but printed on screen, liquibase crashes on the createSequence tag.

This is the changelog
Code:
<?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">
                       
    <changeSet author="chris" id="1">
        <preConditions onFail="MARK_RAN">
            <dbms type="oracle"/>
        </preConditions>
        <createSequence sequenceName="SEQ_GEN_IDENTITY" startValue="10000" />
    </changeSet>

</databaseChangeLog>


And this is the program executing liquibase:
Code:
// package and imports

public class App {

    public static void main(String[] args) throws Exception {
        App a = new App();
        a.run();
    }

    public void run() throws Exception {
        OracleTypeConverter otc = new OracleTypeConverter();
        System.out.println(otc.getDoubleType().toString());

        Connection con = getMysqlConnection("jdbc:mysql://localhost:3306/ht_empty", "test", "test");
        Liquibase liquibase = new Liquibase("C:\temp\changelog_with_generator.xml", new FileSystemResourceAccessor(), new JdbcConnection(con));

                // store the SQL in a String
        StringWriter sw = new StringWriter();

        try {
            liquibase.update(null, sw);
        } catch (Exception e) {
            System.out.println(e.toString());
            e.printStackTrace();
        }
        System.out.println(sw.toString());
    }

    private Connection getMysqlConnection(String url, String username, String password) {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection con = DriverManager.getConnection(url, username, password);
            return con;
        } catch (SQLException ex) {
            ex.printStackTrace();
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        }
        return null;
    }

}


When the SQL is executed on the database no exceptions are thrown. The change set is marked_ran as expected in the databasechangelog table.


Regards,

Chris

Unsubscribe to new topics from this board by clicking here: http://liquibase.org/forum/index.php?action=notifyboard;board=1.0

Regards,
The LiquiBase Community Forum Team.
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Liquibase-user mailing list
Liquibase-user@...
https://lists.sourceforge.net/lists/listinfo/liquibase-user