tasks/mongo.rake in leifcr-mongrations-0.1.6 vs tasks/mongo.rake in leifcr-mongrations-0.1.7
- old
+ new
@@ -1,11 +1,12 @@
namespace :mongo do
+ @path = File.join(Rails.root, "db", "mongrations")
desc "Migrate the database through scripts in db/mongrations. Target specific version with VERSION=x."
task :mongrate => :environment do
- Mongrations::Migrator.migrate("db/mongrations/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
+ Mongrations::Migrator.migrate(@path, ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
end
-
+
namespace :mongrate do
desc 'Rollbacks the database one mongration and re migrate up. If you want to rollback more than one step, define STEP=x. Target specific version with VERSION=x.'
task :redo => :environment do
if ENV["VERSION"]
Rake::Task["mongo:mongrate:down"].invoke
@@ -18,22 +19,27 @@
desc 'Runs the "up" for a given mongration VERSION.'
task :up => :environment do
version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
raise "VERSION is required" unless version
- Mongrations::Migrator.run(:up, "db/mongrations/", version)
+ Mongrations::Migrator.run(:up, @path, version)
end
desc 'Runs the "down" for a given mongration VERSION.'
task :down => :environment do
version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
raise "VERSION is required" unless version
- Mongrations::Migrator.run(:down, "db/mongrations/", version)
+ Mongrations::Migrator.run(:down, @path, version)
end
+
+ desc 'Show the current version of the mongrations'
+ task :version => :environment do
+ puts MongoMapper::Migrator.current_version
+ end
end
-
+
desc 'Rolls the schema back to the previous version. Specify the number of steps with STEP=n'
task :mongo_rollback => :environment do
step = ENV['STEP'] ? ENV['STEP'].to_i : 1
- Mongrations::Migrator.rollback('db/mongrations/', step)
+ Mongrations::Migrator.rollback(@path, step)
end
end