Sha256: 6820463b15078298ce98ac9851fc7de617be333d168c778938830b6b5df7bdc9

Contents?: true

Size: 749 Bytes

Versions: 2

Compression:

Stored size: 749 Bytes

Contents

namespace :db do

  # pass the relative path to the migrations directory by MIGRATION_DIR
  task :setup_migration_dir do
    unless defined?(MIGRATION_DIR)
      migration_dir = ENV["MIGRATION_DIR"] || File.join("db", "migrations")
      MIGRATION_DIR = File.expand_path(File.join(File.dirname(__FILE__), migration_dir))
    end
    FileUtils.mkdir_p MIGRATION_DIR
  end

  # set DIRECTION to migrate down
  desc "Run your system's migrations"
  task :migrate => [:setup_migration_dir] do
    require 'dm-migrations/migration_runner.rb'
    require File.expand_path(File.join(MIGRATION_DIR, "config.rb"))

    Dir[File.join(MIGRATION_DIR, "*.rb")].each { |file| require file }

    ENV["DIRECTION"] != "down" ? migrate_up! : migrate_down!
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dm-migrations-0.10.1 tasks/db.rb
dm-migrations-0.10.0 tasks/db.rb