ActiveRecord-like Migrations for Mongoid
Mongration is a tool for migrating data. It is designed to have the same interface as ActiveRecord's migrations but be used with Mongoid instead of an SQL database.
Mongration supports the following rake tasks:
db:migrate
- migrates all pending migrationsdb:migrate VERSION=123
- moves to the specified version. If the version is greater than the current version, it will move up. If the version is lesser than the current version, it will move down.db:rollback
- rolls back the most recent migrationdb:rollback STEP=N
- rolls back the N most recent migrationsdb:version
- outputs the numeric identifier for the most recent migrationdb:migrate:create
- takes the place of therails generate migration
generatordb:migrate:status
- outputs a table of all files and their migration status
The following versions of Ruby are supported:
- MRI 2.1
- MRI 2.0
- MRI 1.9.3
- JRuby 1.9
Add this line to your application's Gemfile:
gem 'mongration'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mongration --pre
The primary usage will be through the Rake tasks db:migrate
and db:rollback
. Migrate will run all migrations that have not been run before. Rollback will rollback the previous migration.
Migration files have the following structure:
class AddFoo
def self.up
end
def self.down
end
end
The above file could be created with bundle exec rake db:migrate:create[AddFoo]
or bundle exec rake db:migrate:create[add_foo]
.
Contributions are welcome. Please make sure you write a test for any new features or bugs.
- Fork it ( https://github.com/[my-github-username]/mongration/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request