rails-like migrations for java

123 views
Skip to first unread message

phil swenson

unread,
Feb 18, 2013, 12:52:11 PM2/18/13
to java...@googlegroups.com
Has anyone found an open source java (or JVM) project that implements
anything like rails-like migrations? All I see are naked SQL script
migration techniques.

In rails a migration looks something like this:

class AddWallIdToProjects < ActiveRecord::Migration
def change
add_column :projects, :wall_id, :integer
end
end

Thanks

Josh Berry

unread,
Feb 18, 2013, 1:02:40 PM2/18/13
to javaposse
Have you seen scala-migrations? http://code.google.com/p/scala-migrations



--
You received this message because you are subscribed to the Google Groups "Java Posse" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javaposse+...@googlegroups.com.
To post to this group, send email to java...@googlegroups.com.
Visit this group at http://groups.google.com/group/javaposse?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



Wayne Fay

unread,
Feb 18, 2013, 1:19:15 PM2/18/13
to java...@googlegroups.com
> Has anyone found an open source java (or JVM) project that implements
> anything like rails-like migrations? All I see are naked SQL script
> migration techniques.

Safe to assume you've seen liquibase and it was not rails-like enough?
http://liquibase.org/quickstart

Wayne

phil swenson

unread,
Feb 18, 2013, 1:20:30 PM2/18/13
to java...@googlegroups.com
Thanks, that looks really nice!

Raul Guiu

unread,
Feb 18, 2013, 1:33:01 PM2/18/13
to java...@googlegroups.com
An alternative to Liquibase is Flyway: http://flywaydb.org/

Fabrizio Giudici

unread,
Feb 18, 2013, 1:46:53 PM2/18/13
to java...@googlegroups.com, Wayne Fay
+1

--
Fabrizio Giudici - Java Architect @ Tidalwave s.a.s.
"We make Java work. Everywhere."
http://tidalwave.it/fabrizio/blog - fabrizio...@tidalwave.it

Matthew Farwell

unread,
Feb 18, 2013, 2:16:02 PM2/18/13
to Java Posse

+1 for me as well.

Matthew Farwell.

--
You received this message because you are subscribed to the Google Groups "Java Posse" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javaposse+unsubscribe@googlegroups.com.

phil swenson

unread,
Feb 18, 2013, 3:13:00 PM2/18/13
to java...@googlegroups.com
It's better than naked sql, but I think it should be a DSL - not XML.

I would like the ability to add code to my migrations, sometimes data
needs to be transformed during a migration. And code lets you do
dynamic things that XML won't allow.
> --
> You received this message because you are subscribed to the Google Groups "Java Posse" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to javaposse+...@googlegroups.com.

Wayne Fay

unread,
Feb 18, 2013, 3:27:22 PM2/18/13
to java...@googlegroups.com
> I would like the ability to add code to my migrations, sometimes data
> needs to be transformed during a migration. And code lets you do
> dynamic things that XML won't allow.

Liquibase can handle some of this too:
http://liquibase.org/manual/update_data

Wayne

Fabrizio Giudici

unread,
Feb 18, 2013, 3:30:18 PM2/18/13
to java...@googlegroups.com, phil swenson
On Mon, 18 Feb 2013 21:13:00 +0100, phil swenson <phil.s...@gmail.com>
wrote:

> It's better than naked sql, but I think it should be a DSL - not XML.
>
> I would like the ability to add code to my migrations, sometimes data
> needs to be transformed during a migration. And code lets you do
> dynamic things that XML won't allow.

Liquibase can be extended with code:

https://wiki.openmrs.org/display/docs/Liquibase+Extensions

Oscar Hsieh

unread,
Feb 18, 2013, 4:45:16 PM2/18/13
to java...@googlegroups.com
This is a better link

https://liquibase.jira.com/wiki/display/CONTRIB/LiquiBase+Extensions+Portal

Also check out these build-in commands that support custom refactoring

http://www.liquibase.org/manual/modify_sql
http://www.liquibase.org/manual/custom_refactoring_class
http://www.liquibase.org/manual/execute_shell_command

Thanks

--
You received this message because you are subscribed to the Google Groups "Java Posse" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javaposse+unsubscribe@googlegroups.com.

Thomas Queste

unread,
Feb 18, 2013, 3:18:24 PM2/18/13
to java...@googlegroups.com
@Phil: Flyway can mix both SQL and Java migrations.


-- 
Thomas Queste


phil swenson

unread,
Feb 18, 2013, 11:04:38 PM2/18/13
to java...@googlegroups.com
I figured Liquibase had something. But don't scala migrations look
more intuitive?
I've used Rails migrations for years and find the implementation very
nice. Scala migrations looks very, very similar.
>> email to javaposse+...@googlegroups.com.
>> To post to this group, send email to java...@googlegroups.com.
>> Visit this group at http://groups.google.com/group/javaposse?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Java Posse" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to javaposse+...@googlegroups.com.

phil swenson

unread,
Feb 18, 2013, 11:11:23 PM2/18/13
to java...@googlegroups.com
I was looking for a DSL. JDBC is a terrible API, so not a fan of
anything that uses it. Spring's JDBC API is better, but I never
understood why spring was so XML happy. What is the advantage of
wiring in XML vs a simple java class? And the annotation wiring
spreads your wiring throughout the code, so I don't get that either….

Scala migrations is exaclty the type of thing I was thinking about.

Ricky Clarkson

unread,
Feb 18, 2013, 11:15:32 PM2/18/13
to javaposse
Spring's JDBC stuff can be used without any other parts of Spring, no XML, no annotations, no reflection-based injection.  It provides a reasonably functional-like interface to handling ResultSets, and with a little pain it improves over straight JDBC in terms of specifying variable numbers of parameters safely (e.g., an IN clause).

It's not perfect but it is the one bit of Spring I use by choice.

Dan Stine

unread,
Feb 18, 2013, 9:28:12 PM2/18/13
to java...@googlegroups.com

phil swenson

unread,
Feb 19, 2013, 8:59:13 AM2/19/13
to java...@googlegroups.com
good find. I like their description: "A pluggable parser for
Liquibase that allows the creation of changelogs in a Groovy DSL,
rather than hurtful XML"
Reply all
Reply to author
Forward
0 new messages