Class: DB::Migrate::DropTable

Inherits:
Object
  • Object
show all
Defined in:
lib/db/migrate/drop_table.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, if_exists: false) ⇒ DropTable

Returns a new instance of DropTable.



11
12
13
14
# File 'lib/db/migrate/drop_table.rb', line 11

def initialize(name, if_exists: false)
	@name = name
	@if_exists = if_exists
end

Instance Method Details

#call(session) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/db/migrate/drop_table.rb', line 20

def call(session)
	statement = session.clause("DROP TABLE")
	
	# Use feature detection for IF EXISTS support
	features = session.connection.features
	if @if_exists && features.conditional_operations?
		statement.clause("IF EXISTS")
	end
	
	statement.identifier(@name)
	
	Console.logger.info(self, statement)
	statement.call
end

#if_exists!Object



16
17
18
# File 'lib/db/migrate/drop_table.rb', line 16

def if_exists!
	@if_exists = true
end