Is there a version control system for database structure changes?

In Ruby on Rails, there’s a concept of a migration — a quick script to change the database.

You generate a migration file, which has rules to increase the db version (such as adding a column) and rules to downgrade the version (such as removing a column). Each migration is numbered, and a table keeps track of your current db version.

To migrate up, you run a command called “db:migrate” which looks at your version and applies the needed scripts. You can migrate down in a similar way.

The migration scripts themselves are kept in a version control system — whenever you change the database you check in a new script, and any developer can apply it to bring their local db to the latest version.

Leave a Comment