Sha256: ccc103db92f41f54cb9066130c82cf5cb14d4e242d22700cc3eedb5dc1edb787

Contents?: true

Size: 954 Bytes

Versions: 13

Compression:

Stored size: 954 Bytes

Contents

namespace :db do
  desc "Generates migrations as per structure design in your models and runs them"
  task :upgrade => :environment do
    if Migrant::MigrationGenerator.new.run
      puts "\nInvoking db:migrate for #{Rails.env} environment."
      Rake::Task['db:migrate'].invoke

      # If RAILS_ENV is explicitly specified, don't clone out to test
      unless ENV['RAILS_ENV']
        puts "Migrated. Now, cloning out to the test database."
        Rake::Task['db:test:clone'].invoke
      end
    end
  end
  
  desc "Provides a shortcut to rolling back and discarding the last migration"
  task :downgrade => :environment do
    Rake::Task['db:rollback'].invoke
    Dir.chdir(Rails.root.join('db', 'migrate')) do
      last_migration = Dir.glob('*.rb').sort.last and
      File.unlink(last_migration) and
      puts "Removed #{Dir.pwd}/#{last_migration}."      
    end
  
    Rake::Task['db:test:clone'].invoke unless ENV['RAILS_ENV']
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
migrant-1.5.0 lib/tasks/db.rake
migrant-1.4.3 lib/tasks/db.rake
migrant-1.4.1 lib/tasks/db.rake
migrant-1.4.0 lib/tasks/db.rake
migrant-1.3.2 lib/tasks/db.rake
migrant-1.3.1 lib/tasks/db.rake
migrant-1.3.0 lib/tasks/db.rake
migrant-1.2.8 lib/tasks/db.rake
migrant-1.2.7 lib/tasks/db.rake
migrant-1.2.5 lib/tasks/db.rake
migrant-1.2.2 lib/tasks/db.rake
migrant-1.2.1 lib/tasks/db.rake
migrant-1.2.0 lib/tasks/db.rake