views:

83

answers:

3

Our application isn't going to use rails for any part of its final state, but migrations are a fantastic way to define schema in my experience, so I'd like to use just that one aspect of rails.

Is this a reasonable thing to do? If not, are there any tools out there than can be used to perform the same sort of job? We have a three-stage deployment environment, with test, QA, and production tiers, so this maps pretty well to the tiers that rails uses. However, we're a python shop primarily, so a pythonic equivalent would be nifty.

A: 

I would google the python equivalents. Migrations are fun, and if you like working that way and it works, then of course it's reasonable. You should follow the advice however and periodically check in schema.rb, rather than counting on migrations to build your production servers.

John Lockwood
+2  A: 

I do not have any particular alternative to give you. But if you decide to use the migrations anyway, you must know that you do not need to use the whole rails architecture only for migrations.

As long as you have the active_record gem installed, you can do : in your Rakefile

require 'active_record'
require 'yaml'

task :default => :migrate

In a file on the same path :

desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"
task :migrate => :environment do
    ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
end

task :environment do
    ActiveRecord::Base.establish_connection(YAML::load(File.open('database.yml')))
    ActiveRecord::Base.logger = Logger.new(File.open('database.log', 'a'))
end

And your migrations in the db/migrate folder. You do not need the whole activeresources and all of rails base.

Damien MATHIEU
A: 

I know you are a Python shop but there is a PHP port of the ActiveRecord Migrations package which is very standalone.

http://code.google.com/p/ruckusing/

Cody Caughlan