Hello I use flyway for versioning my database however i'm starting now and i'm with a doubt. If i have two files with sqls instructions and the first file all sqls instructions are correct but in the second there is an error and if i do migrate with the flyway the first file 's instructions will be included in my database , however i wanted it to be inserted so that all instructions of the two files were correct someone already go through something like that?
my code is below.
flyway.setDataSource(con,user,pass);
flyway.setSchemas("database");
//Repara o banco para inserir as novas migrações
flyway.repair();
//Insere as migrações no banco de dados
flyway.migrate();
V1_file.sql
CREATE TABLE flyway (
name VARCHAR(100)
);
V2_file.sql
alter table flyway add x int
alter table flyway add y int
v3_file.sql
CREATE TABLE flyway (
name VARCHAR(100)
);
the flyway table already exists if it happened a similar situation so as to enter the data every sql files did not have any errors Is very simple but i really need this.
Flyway runs each migration inside a transaction. If you want statements to be committed or rolled back together, you have to place them within the same .sql file.