Sha256: d1d5f1b4ee9d0f0818f2eb866da84102123eb7496cc8664a43fbc4c48e6817da

Contents?: true

Size: 892 Bytes

Versions: 5

Compression:

Stored size: 892 Bytes

Contents

module MigrationTools
  module MigrationExtension

    attr_accessor :migration_group

    def group(arg = nil)
      unless MigrationTools::MIGRATION_GROUPS.member?(arg.to_s)
        raise "Invalid group \"#{arg.to_s}\" - valid groups are #{MigrationTools::MIGRATION_GROUPS.inspect}"
      end

      self.migration_group = arg.to_s
    end

    def migrate_with_forced_groups(direction)
      if MigrationTools.forced? && migration_group.blank?
        raise "Cowardly refusing to run migration without a group. Read https://github.com/morten/migration_tools/blob/master/README.rdoc"
      end
      migrate_without_forced_groups(direction)
    end
  end
end

ActiveRecord::Migration.class_eval do
  extend MigrationTools::MigrationExtension
  class << self
    alias_method_chain :migrate, :forced_groups
  end
end
ActiveRecord::MigrationProxy.delegate :migration_group, :to => :migration

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
migration_tools-1.0.0 lib/migration_tools/migration_extension.rb
migration_tools-0.3.0 lib/migration_tools/migration_extension.rb
migration_tools-0.2.1 lib/migration_tools/migration_extension.rb
migration_tools-0.1.7 lib/migration_tools/migration_extension.rb
migration_tools-0.1.6 lib/migration_tools/migration_extension.rb