README.markdown in standalone_migrations-0.1.1 vs README.markdown in standalone_migrations-0.1.2

- old
+ new

@@ -1,19 +1,18 @@ Rails migrations in non-Rails (and non Ruby) projects. -For this code to work you need Ruby, Gems, ActiveRecord, Rake and a suitable database driver installed. USAGE ===== -Install Ruby, RubyGems then: +Install Ruby, RubyGems and a ruby-database driver (e.g. `gem install mysql`) then: sudo gem install standalone_migrations Add to `Rakefile` in your projects base directory: begin require 'standalone_migrations' StandaloneMigrations.tasks - rescue LoadError - puts 'gem install standalone_migrations to get db:migrate:* tasks!' + rescue LoadError => e + puts "gem install standalone_migrations to get db:migrate:* tasks! (Error: #{e})" end Add database configuration to `config/database.yml` in your projects base directory e.g.: development: adapter: mysql @@ -26,40 +25,45 @@ socket: /var/run/mysqld/mysqld.sock test: ...something similar... -To create a new database migration run: +### To create a new database migration: rake db:new_migration name=FooBarMigration edit migrations/20081220234130_foo_bar_migration.rb -and fill in the up and down migrations. To apply your newest migration +... and fill in the up and down migrations [Cheatsheet](http://dizzy.co.uk/ruby_on_rails/cheatsheets/rails-migrations). +If you're lazy and want to just execute raw SQL: + + def self.up + execute "insert into foo values (123,'something');" + end + + def self.down + execute "delete from foo where field='something';" + end + +### To apply your newest migration: + rake db:migrate -To migrate to a specific version (for example to rollback) +### To migrate to a specific version (for example to rollback) rake db:migrate VERSION=20081220234130 -To migrate a specific database (for example your "testing" database) +### To migrate a specific database (for example your "testing" database) rake db:migrate RAILS_ENV=test -CREDIT -====== -This work is based on Lincoln Stoll's blog post: http://lstoll.net/2008/04/stand-alone-activerecord-migrations/ -and David Welton's post http://journal.dedasys.com/2007/01/28/using-migrations-outside-of-rails +### To execute a specific up/down of one single migration -FURTHER HELP + rake db:migrate:up VERSION=20081220234130 + +Contributors ============ -A good source to learn how to use migrations is: -http://dizzy.co.uk/ruby_on_rails/cheatsheets/rails-migrations -or if you're lazy and want to just execute raw SQL +This work is based on [Lincoln Stoll's blog post](http://lstoll.net/2008/04/stand-alone-activerecord-migrations/) and [David Welton's post](http://journal.dedasys.com/2007/01/28/using-migrations-outside-of-rails). - def self.up - execute "insert into foo values (123,'something');" - end - - def self.down - execute "delete from foo where field='something';" - end + - [Todd Huss](http://gabrito.com/) + - [Steve Hodgkiss](http://stevehodgkiss.com/)`s [activerecord-migrator-standalone](http://github.com/stevehodgkiss/activerecord-migrator-standalone) + - [Michael Grosser](http://pragmatig.wordpress.com) \ No newline at end of file