instance method
run
Ruby on Rails 6.1.7.10
Since v4.0.13Signature
run(*migration_classes)
Runs the given migration classes. Last argument can specify options:
-
:direction (default is :up)
-
:revert (default is false)
Parameters
-
migration_classesrest
Source
# File activerecord/lib/active_record/migration.rb, line 813
def run(*migration_classes)
opts = migration_classes.extract_options!
dir = opts[:direction] || :up
dir = (dir == :down ? :up : :down) if opts[:revert]
if reverting?
# If in revert and going :up, say, we want to execute :down without reverting, so
revert { run(*migration_classes, direction: dir, revert: true) }
else
migration_classes.each do |migration_class|
migration_class.new.exec_migration(connection, dir)
end
end
end
Defined in activerecord/lib/active_record/migration.rb line 813
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Migration