2

I successfully ran v1 migration with a create table DDL. I copied same to v2 file and ran - got the expected validation error message:

Migrating to version 1.0.002 com.googlecode.flyway.core.exception.FlywayException: Error executing statement at line 1: create table people(id number(10) primary key, name varchar2(301)) Caused by java.sql.SQLSyntaxErrorException: ORA-00955: name is already used by a n existing object MigrationException: Migration to version 1.0.002 failed! Please restore backups and roll back database and code

I corrected the v2 file and ran flyway migrate again. Giving back the error message

Current schema version: 1.0.002 MigrationException: Migration to version 1.0.002 failed! Please restore backups and roll back database and code

I am not in a stage where a database backup is taken - simple trying to execute a fixed DDL. I don't currently see a solution short of flyway clean. Why cannot flyway try to execute FAILED versions again (if the checksum has changed)? Or shouldn't there be a flyway rollback command?

I know I can very well modify the code to make it that way, but was there any reason why you chose it to behave this way?

skaffman
  • 398,947
  • 96
  • 818
  • 769
dileeph
  • 71
  • 4

1 Answers1

2

The problem with simply reexecuting is that some changes might already have been applied, which will cause the migration to fail.

There are two solutions to this:

  • Use a database that supports DDL transactions such as PostgreSQL, SQLServer or DB2
  • Perform a manual cleanup of the modified structures and the metadata table before reapplying
Axel Fontaine
  • 34,542
  • 16
  • 106
  • 137