Class: Ardb::CLI::DropCommand

Inherits:
Object
  • Object
show all
Includes:
ValidCommand
Defined in:
lib/ardb/cli/commands.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.command_nameObject



156
157
158
# File 'lib/ardb/cli/commands.rb', line 156

def self.command_name
  "drop"
end

.command_summaryObject



160
161
162
# File 'lib/ardb/cli/commands.rb', line 160

def self.command_summary
  "Drop the configured DB"
end

Instance Method Details

#run(argv, *args) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/ardb/cli/commands.rb', line 164

def run(argv, *args)
  super

  begin
    Ardb.init(true)
    Ardb.adapter.drop_db
    @stdout.puts(
      "dropped #{Ardb.config.adapter} db #{Ardb.config.database.inspect}",
    )
  rescue ActiveRecord::NoDatabaseError
    @stderr.puts(
      "error: database #{Ardb.config.database.inspect} does not exist",
    )
  rescue => ex
    @stderr.puts ex
    @stderr.puts "error dropping #{Ardb.config.database.inspect} database"
    raise CommandExitError
  end
end