Axel Fontaine is a software development expert and freelance consultant based in Munich. He is specialized in Continuous Delivery. He has extensive experience with the full software development lifecycle. He hates complexity with a passion. As an architect, developer, coach and consultant he helps his customers improve the way they develop and deliver software. To alleviate one of the traditional pain points, he started Flyway, the Agile Database Migration Framework for Java. He frequently speaks at Java User Groups. Axel is a DZone MVB and is not an employee of DZone and has posted 7 posts at DZone. You can read more from them at their website. View Full User Profile

Flyway 2.1 released with automatic schema creation

03.05.2013
| 3133 views |
  • submit to reddit

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


Cheers
@axelfontaine

P.S.: This release also marks the move to GitHub: github.com/flyway/flyway. Check it out and keep the pull requests coming!

0
Published at DZone with permission of Axel Fontaine, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)