| Class | Mongoid::Migration |
| In: |
lib/mongoid_rails_migrations/active_record_ext/migrations.rb
|
| Parent: | Object |
Data migrations can manage the modification of data. It‘s a solution to the common problem of modifying data between code revisions within a document oriented database.
Example of simple migration for a system dependency:
class AddBaselineSurveySchema < Mongoid::Migration
def self.up
SurveySchema.create(:label => 'Baseline Survey')
end
def self.down
SurveySchema.where(:label => 'Baseline Survey').first.destroy
end
end
By default, Rails generates migrations that look like:
20080717013526_your_migration_name.rb
The prefix is a generation timestamp (in UTC).
If you‘d prefer to use numeric prefixes, you can turn timestamped migrations off by setting:
Mongoid.config.timestamped_migrations = false
In environment.rb.