Method: Ardb::CLI::GenerateMigrationCommand#run

Defined in:
lib/ardb/cli/commands.rb

#run(argv, *args) ⇒ Object



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/ardb/cli/commands.rb', line 147

def run(argv, *args)
  super

  begin
    Ardb.init(false)

    require "ardb/migration"
    migration = Ardb::Migration.new(Ardb.config, @clirb.args.first)
    migration.save!
    @stdout.puts "generated #{migration.file_path}"
  rescue Ardb::Migration::NoIdentifierError => exception
    error = ArgumentError.new("MIGRATION-NAME must be provided")
    error.set_backtrace(exception.backtrace)
    raise error
  rescue StandardError => e
    @stderr.puts e
    @stderr.puts e.backtrace.join("\n")
    @stderr.puts "error generating migration"
    raise CommandExitError
  end
end