I'm not sure if this is possible, but I am trying to load a migration saved in an SQL file programmatically through the Flyway Java API. I have an SQL file saved in the base classpath (for simplicity right now) as V1__Initial_version.sql with a simple table creation statement:
CREATE TABLE test_user (
name VARCHAR(25) NOT NULL, PRIMARY KEY(name)
);
Then in the Java program I use
Flyway flyway = new Flyway();
flyway.setDataSource(jdbc_url, user, password);
int migrations = flyway.migrate(); // Just to check the # of migrations applied
I see the ClassPathScanner looking through the classpath for valid migrations, but it seems to ignore the sql migration file. The same sql migration file works fine when I call flyway migrate from the command line. I created a java class and inherited from the JdbcMigrations class and the ClassPathScanner picks that up just fine. What do I need to do to get the .sql file picked up by the Java ClassPathScanner and used as a valid migration?
BIGGER PICTURE
Maybe I am going about this incorrectly in the first place so I'll add what I'm trying to do. I am trying to set up a test DB that I can use, nuke, and rebuild in between tests. I.E. TestA enters something into the table, the pre-test function would then clean up the DB and reset it, then TestB would have a clean DB and empty tables to execute it's tests against. I am using flyway.clean() and flyway.migrate() in the pre-test function but it destroys the schema_version table along with everything else then the migrate doesn't rebuild from the previous baseline.
Any help is appreciated! Thanks!