README.markdown in standalone_migrations-0.4.8 vs README.markdown in standalone_migrations-0.4.10

- old
+ new

@@ -52,20 +52,49 @@ rake db:new_migration name=FooBarMigration edit db/migrations/20081220234130_foo_bar_migration.rb ... 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: +#### If you really want to, you can 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 +#### Even better, you can use the _generate_ task to create the initial migration #### + +The general form is: + + rake db:generate model="model_name" fields="type:column_name0 type:column_name1 ... type:column_namen" + +You can have as many fields as you would like. + +An example to create a Person table with 3 columns (and it will automatically add the t.timestamps line) + + rake db:generate model="Person" fields="string:first_name string:last_name integer:age" + +This will create a migration in db/migrations/ + + class CreatePerson < ActiveRecord::Migration + def self.up + create_table :Person do |t| + t.string :first_name + t.string :last_name + t.integer :age + t.timestamps + end + end + + def self.down + drop_table :Person + end + end + ### To apply your newest migration: rake db:migrate ### To migrate to a specific version (for example to rollback) @@ -101,13 +130,15 @@ And migrations for this database would be created in db/migrate/widgets subdirectory. Contributors ============ -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). - - [Todd Huss](http://gabrito.com/) + - [Two Bit Labs](http://twobitlabs.com/) - [Michael Grosser](http://pragmatig.wordpress.com) - [Eric Lindvall](http://bitmonkey.net) - [Steve Hodgkiss](http://stevehodgkiss.com/) - [Rich Meyers](https://github.com/richmeyers) - [Wes Bailey](http://exposinggotchas.blogspot.com/) + - [Robert J. Berger](http://blog.ibd.com/) + +This work is originally 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).