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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With