RVA
RVA

Reputation: 870

How does flyway init its database

I'm having trouble to configure flyway with a postgresql data source wihtin a spring java web-app.

Flyway seems to not execute the migrate operation even if I configure like this :

<bean id="flyway" class="com.googlecode.flyway.core.Flyway" init-method="migrate">
    <property name="dataSource" ref="dataSource"/>
    <property name="table" value="blankapp_schema_version" />
    <property name="disableInitCheck" value="true" />   
</bean>

It does not create the blankapp_schema_version table when I run my tomcat (v6) server within eclipse. I had to change the init-method to "init" to make him create the table.

the blankapp_schema_version table is now created, but even if I set again the init-method to "migrate", my first script (which is name as V001_init.sql) and just doing a simple create table seems not to be exectuted, as I get no table created nor an additional line with my current version in blankapp_schema_version table.

Further more, I got no error in my tomcat logs I've setted the logback from com.google.flyway to trace and the only lines I have are :

17:25:48.822 [main] DEBUG c.g.f.c.dbsupport.DbSupportFactory - Database: PostgreSQL
17:25:48.823 [main] DEBUG com.googlecode.flyway.core.Flyway - Schema: public

and nothing more.

Some context:

My bean "dataSource" is bound as following :

<jee:jndi-lookup jndi-name="jdbc/BlankAppDataSource" id="dataSource" /> 

And in my META-INF/context.xml I have :

<Context>
     <Resource name="jdbc/BlankAppDataSource"
            auth="Container"
            type="javax.sql.DataSource"
            username="postgres"
            password="Weblogic1"
            schema="public"
            driverClassName="org.postgresql.Driver"
            url="jdbc:postgresql://localhost:5432/rvandecaveye" 
    />
</Context>

Upvotes: 2

Views: 3633

Answers (1)

josephtaylor.art
josephtaylor.art

Reputation: 132

If the version of your migration is less than or equal to the schema version in the blankapp_schema_version table, it will not run the migration.

You can set the value of the initial schema version by adding the property initDescription .

So to run your V001 script, the initDescription parameter should be 0.

Upvotes: 2

Related Questions