Method: Hanami::CLI::Commands::App::DB::Migrate#call

Defined in:
lib/hanami/cli/commands/app/db/migrate.rb

#call(target: nil, app: false, slice: nil, gateway: nil, dump: true, command_exit: method(:exit)) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/hanami/cli/commands/app/db/migrate.rb', line 20

def call(target: nil, app: false, slice: nil, gateway: nil, dump: true, command_exit: method(:exit), **)
  databases(app: app, slice: slice, gateway: gateway).each do |database|
    if migrations_dir_missing?(database)
      warn_on_missing_migrations_dir(database)
    elsif no_migrations?(database)
      warn_on_empty_migrations_dir(database)
    else
      migrate_database(database, target: target)
    end
  end

  # Only dump for the initial command, not a re-run of the command in test env
  if dump && !re_running_in_test?
    run_command(
      Structure::Dump,
      app: app, slice: slice, gateway: gateway,
      command_exit: command_exit
    )
  end

  re_run_development_command_in_test
end