Cover by Edd Dumbill, Simon St. Laurent, Eric J Gruber

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Chapter 10. Managing Databases with Migrations

Migrations might seem strange at first, but over time they’ll become a very ordinary part of your work, whether you generate them automatically or customize them by hand. Rails’ approach to managing data structures is very different from the traditional separation of database design from programming. While Rails still maintains a separate toolkit for defining data structures, that toolkit attempts to improve on the traditional SQL Data Definition Language (DDL) by wrapping DDL in Ruby code.

Migrations are something of a world of their own in the Rails environment, but they are still recognizably Rails, built into the same development process. Migrations are all written in Ruby code, using a fairly small set of conventions. This book has used migrations throughout—you can write much of a Rails application without them—but until the last chapter (and then only once), those migrations were generated using Rails’ inventive scripts. Once you move past those scripts, migrations are a little more difficult, but still not that complicated.

Note

The details of migrations may not be your first priority. You can safely skip this chapter and come back to it if database and data structure management seem like good reading for a really rainy day.

What Migrations Offer You

Migrations are part of Rails’ general effort to separate developers from direct contact with databases. From a Rails perspective, databases are kind of a “giant hash in the sky,” a conveniently ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required