Flyway 2.1 released with automatic schema creation
Join the DZone community and get the full member experience.Join For Free
flyway 2.1 is out!
highlights of this release:
- automatic schema creation
- sql migrations from filesystem (instead of only from classpath)
- command-line tool shared installation (freely configurable sql and jar folders)
automatic schema creation
flyway has always made it easy to get started. simply point it at an empty schema and of you go. and now it just got even better. flyway has gained the ability to automatically create (and drop) schemas.
how does it work? in flyway-style, fully automatic and transparent for the user:
flyway flyway = new flyway(); flyway.setdatasource(…); flyway.setschemas(“new_schema_1”, “new_schema_2”); flyway.migrate();
and voilà! if the schemas already exist, flyway uses them, otherwise flyway creates them. running this against and empty db will produce this:
sql migrations from filesystem (instead of only from classpath)
the most efficient way to make sure your database and code never get out of sync is to run database migrations on application startup. there are however a number of scenarios where this is not easily feasible, and this is why the maven plugin, the ant tasks and the command-line tool were created. in order to better serve these environments (and the users of the api for whom it is not practical to ship the migrations on the classpath), flyway 2.1 now introduces support for loading sql migrations directly from the filesystem. all you have to do, is prefix a location with filesystem: and you’re good to go:
flyway flyway = new flyway(); flyway.setdatasource(…); flyway.setlocations(“filesystem:/path/to/migrations”); flyway.migrate();
command-line tool shared installation (freely configurable sql and jar folders)
the command-line tool has made it easy to get started for users in a scripting environment or without a maven or ant installation available. so far, however, you could only place jdbc drivers and migrations within its own installation path. this made sharing a single installation of the tool amongst projects harder that it should be. these restrictions have now been lifted. you can have a single installation and point to project-specific drivers and migrations like this:
flyway.sh migrate –locations=filesystem:/path/to/migrations –jardir=/path/to/jdbc/drivers
in addition to these three new features, this releases packs numerous bug fixes and small improvements . all of which wouldn’t have been possible without the tireless work of all the ones who contributed issue reports and submitted fixes and pull requests. thank you!
so go ahead, and grab flyway 2.1 while it’s hot: flywaydb.org
p.s.: this release also marks the move to github: github.com/flyway/flyway . check it out and keep the pull requests coming!
Opinions expressed by DZone contributors are their own.