module AlsoMigrate module Migrator def self.included(base) unless base.respond_to?(:migrate_with_also_migrate) base.send :include, InstanceMethods base.class_eval do alias_method :migrate_without_also_migrate, :migrate alias_method :migrate, :migrate_with_also_migrate end end end module InstanceMethods def migrate_with_also_migrate Object.subclasses_of(ActiveRecord::Base).each do |klass| if klass.respond_to?(:also_migrate_config) AlsoMigrate.create_tables(klass) end end ensure migrate_without_also_migrate end module AlsoMigrate class <