Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate migrations outside Rails

I'm using ActiveRecord outside Rails. I would want a program to generate the skeleton of a migration ( as well as a system to collect and maintain them ).

Can anyone make a suggestion?

like image 620
Mouse.The.Lucky.Dog Avatar asked Aug 09 '12 11:08

Mouse.The.Lucky.Dog


1 Answers

There is another gem called otr-activerecord. This gem provides following tasks:

  • rake db:create
  • rake db:create_migration[name]
  • rake db:drop
  • rake db:environment:set
  • rake db:fixtures:load
  • rake db:migrate
  • rake db:migrate:status
  • rake db:rollback
  • rake db:schema:cache:clear
  • rake db:schema:cache:dump
  • rake db:schema:dump
  • rake db:schema:load
  • rake db:seed
  • rake db:setup
  • rake db:structure:dump
  • rake db:structure:load
  • rake db:version

All you need to do is to install it and add a Rakefile with content

load 'tasks/otr-activerecord.rake'
OTR::ActiveRecord.configure_from_file! 'config/database.yml'

I prefer this gem over active_record_migrations or Standalone Migration because those two gems depend on railties, which is almost the entire Rails. For example, Nokogiri takes a long time to compile, and takes a lot of spaces.

like image 164
Franklin Yu Avatar answered Oct 16 '22 16:10

Franklin Yu