This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Wed Jul 08 15:43:21 -0700 2009 | |
| |
README | Tue Jul 21 11:04:23 -0700 2009 | |
| |
Rakefile | Wed Jul 08 15:43:21 -0700 2009 | |
| |
config/ | Wed Jul 08 15:43:21 -0700 2009 | |
| |
lib/ | Sat Apr 04 15:41:14 -0700 2009 | |
| |
migrations/ | Sat Apr 04 15:41:13 -0700 2009 |
README
STANDALONE MIGRATIONS --------------------- This project allows you to use Rails migrations in non-Rails (and non Ruby) projects. I created it because not all of my projects are on Rails but I still think Rails migrations are the best way to manage a database schema. For this code to work you need Ruby, Gems, ActiveRecord, Rake and a suitable database driver installed. Email me at todd dot huss dot work at gmail dot com if you have a patch that adds functionality or fixes a bug. Or post a comment here: http://gabrito.com/post/standalone-migrations-using-rails-migrations-in-non-rails-projects TODO ---- Turn into a gem USAGE ----- To create a new database migration run: 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 rake db:migrate 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) 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 INSTALLATION ------------ Many systems have pre-existing packages for Ruby and Ruby gems so in most cases that should be pretty straightforward. Once Ruby and Gem is installed, as root run: gem install -y activerecord rake mysql cd standalone-migrations/config cp database_sample.yml database.yml edit database.yml (and change settings for your database, the development database is the default) cd ../ rake db:migrate (this will just create the schema_migrations table) (If you're familiar with rails there are also the tasks db:schema:dump and db:schema:load) DOCUMENTATION ------------- 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 def self.up execute "insert into foo values (123,'something');" end def self.down execute "delete from foo where field='something';" end







