instance method migrate

Ruby on Rails 7.0.10

Since v7.0.10

Available in: v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

migrate(target_version = nil, &block)

Runs the migrations in the migrations_path.

If target_version is nil, migrate will run up.

If the current_version and target_version are both 0 then an empty array will be returned and no migrations will be run.

If the current_version in the schema is greater than the target_version, then down will be run.

If none of the conditions are met, up will be run with the target_version.

Parameters

target_version opt = nil
block block
Source
# File activerecord/lib/active_record/migration.rb, line 1139
    def migrate(target_version = nil, &block)
      case
      when target_version.nil?
        up(target_version, &block)
      when current_version == 0 && target_version == 0
        []
      when current_version > target_version
        down(target_version, &block)
      else
        up(target_version, &block)
      end
    end

Defined in activerecord/lib/active_record/migration.rb line 1139 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::MigrationContext

Type at least 2 characters to search.

↑↓ navigate · open · esc close