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 if ::AlsoMigrate.classes ::AlsoMigrate.classes.uniq.each do |klass| if klass.respond_to?(:also_migrate_config) AlsoMigrate.create_tables(klass) end end end rescue Exception => e puts "AlsoMigrate error: #{e.message}" puts e.backtrace.join("\n") ensure migrate_without_also_migrate end module AlsoMigrate class <