Sun finally backs another language Nursery rhythms are all diferent in the US compared to the UK
Sep 07

ActiveRecord Migrations: Not just for Rails projects

Tech Add comments

Pairing today, I saw someone go through the following process:

  • Went to play with some SQL as we prototype a new feature
  • Say ’screw it’ and jump in to use migrations to change the schema as it was easier to do so that grok the SQL in this case

This again showed me how ActiveRecord migrations are so useful, that I would be very tempted to use them for a non-Rails project at this point.

That isn’t that far fetched. I can not think of a Java project in recent years that didn’t have a bit of Ruby (or Groovy, or …) in there as helper scripts at the very least. There are no “Java projects”. You always have many languages involved (SQL, shell scripts, HTML, XML, …) in a project. As you do useful things in your projects you often generalize them into libraries that you use on future projects.

ActiveRecord migrations could easily fit into this world. Versioning, and managing the versions of database schema, and data, can often be a pain in the arse. Migrations does the job in style, and is useful standalone.

Of course, you could role up some Java solutions, but it is hard to come up with a DSL quite as nice, and migrations will get better and better. There are still rough edges that we run into. When sucking out an existing schema with enumerations a field with varchar(0) was created. Not too helpful, and yet another look into how good Rails is for green-fields, but it still takes a bit more work for legacy. This is normal though.

4 Responses to “ActiveRecord Migrations: Not just for Rails projects”

  1. Charles Oliver Nutter Says:

    This is particularly timely now that migrations are working under JRuby for multiple databases, including some that Rails doesn’t normally even support like Derby and HSQLDB…plus we have solid support everywhere for SQL Server and migrations support for Firebird.

    Ola brought up this exact same thought the other day and I was blinded by the brilliance of it. Good god, if I could now use migrations for all my Java projects just as easily as for rails projects…well there goes the six-figure DBA salaries to alter a bloody column or import test data for me. It would be a beautiful thing, and with Rails, Rake, and migrations working in JRuby, it’s a no-brainer to start using it.

  2. anjan bacchu Says:

    hi there,

    very cool! Only yesterday, something similar hit me after reading Bruce Tate’s article on IBM Developerworks.

    Will be interesting to use JRuby/migrations!


  3. jRuby Says:

    The freedom of doing database refactoring while developing code is something every framework / technology / whateverelse should implement to make developers happy. I am willing to see its adoption everywhere.

  4. chanel replica handbags Says:

    thanks for your share,very good.thank you!

Leave a Reply

Spam is a pain, I am sorry to have to do this to you, but can you answer the question below?

Q: Type in the word 'cricket'