user2406947
user2406947

Reputation: 31

Error Running Mixed SQL and Java Migrations - Error executing statement at line 1: package db.migration

I'm trying to run a mixture of SQL and Java migrations via Maven based on the example from Axel Fontaine here: http://www.methodsandtools.com/tools/flyway.php

Basically I am trying to execute several SQL migrations, followed by a java migration (to load BLOBS into a table), then followed by another SQL migration.

The first set of SQL migrations run fine. If I specify a file extension of .java for the Java migration, it gets ignored. If I specify a file extension of .sql for the Java migration, it gets run in the correct sequence, but I get the following error:

[ERROR] com.googlecode.flyway.core.api.FlywayException: Error executing statement at line 1: package db.migration [ERROR] Caused by org.postgresql.util.PSQLException: ERROR: syntax error at or near "package" Position: 1 [ERROR] com.googlecode.flyway.core.api.FlywayException: Migration of schema "test" to version 1.0.0106 failed! Changes successfully rolled back.

Here is the head of my Java migration file:

package db.migration;
import com.googlecode.flyway.core.api.migration.jdbc.JdbcMigration;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.io.File;

Any ideas as to what I'm doing wrong?

Upvotes: 2

Views: 980

Answers (1)

user2406947
user2406947

Reputation: 31

Okay, I finally figured out what was going on. While Flyway allows version numbers that contain "." in the name (ex. V1.0.0000_filename), apparently it is not supported for Java migration class names. I changed the class name to use "" instead of "." (V1_0_1000_filename) and that allowed me to get past the original error.

Upvotes: 1

Related Questions