Class: DbAgile::Command::SQL::Drop

Inherits:
DbAgile::Command show all
Defined in:
lib/dbagile/command/sql/drop.rb

Overview

Drop a table from a SQL database

Usage: dba #DbAgile::Command#command_name TABLE

This command issues a “DROP TABLE …” in the DbAgile’s command chain, therefore targetting the schema of the physical SQL database and bypassing other schemas if present (announced and effectice schemas in particular).

As it may lead to divergences between schemas, and between effective and physical schemas in particular, you should consider using schema:* commands instead, when possible.

Constant Summary

Constants inherited from DbAgile::Command

CATEGORIES, CATEGORY_NAMES

Instance Attribute Summary collapse

Attributes inherited from DbAgile::Command

#environment

Attributes included from ClassMethods

#description, #summary, #usage

Instance Method Summary collapse

Methods inherited from DbAgile::Command

#add_options, #category, #check_command, #command_name, #description, #initialize, #options, #run, #set_default_options, #show_help, #summary, #unsecure_run, #usage

Methods included from ClassMethods

#build_command_options, #build_me, #category, #command_for, #command_name, #command_name_of, #each_subclass, #inherited, #ruby_method_for, #subclasses

Methods included from Robust

#ambigous_argument_list!, #assumption_error!, #bad_argument_list!, #has_command!, #is_in!, #valid_argument_list!, #valid_read_file!

Methods included from DbAgile::Core::IO::Robustness

#has_database!, #valid_database_name!, #valid_database_uri!, #valid_schema_files!

Constructor Details

This class inherits a constructor from DbAgile::Command

Instance Attribute Details

#tableObject

Table which must be dropped



21
22
23
# File 'lib/dbagile/command/sql/drop.rb', line 21

def table
  @table
end

Instance Method Details

#execute_commandObject

Executes the command



29
30
31
32
33
34
35
# File 'lib/dbagile/command/sql/drop.rb', line 29

def execute_command
  with_current_connection do |connection|
    connection.transaction do |t|
      t.drop_table(self.table)
    end
  end
end

#normalize_pending_arguments(arguments) ⇒ Object

Normalizes the pending arguments



24
25
26
# File 'lib/dbagile/command/sql/drop.rb', line 24

def normalize_pending_arguments(arguments)
  self.table = valid_argument_list!(arguments, Symbol)
end