Class: HerokuSchemas::Drop

Inherits:
SchemaCommand show all
Defined in:
lib/heroku-schemas/drop.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from SchemaCommand

#write

Constructor Details

#initialize(options) ⇒ Drop

Returns a new instance of Drop.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/heroku-schemas/drop.rb', line 5

def initialize(options)
  super(options)

  @string_reference = options[:string_reference]
  raise 'Context app not provided' if @context_app.blank?
  raise 'Schema reference not provided' if @string_reference.blank?
  
  related_apps = [@context_app, @string_reference.split(':').first].uniq
  @schema = HerokuSchemas::SchemaReference.new(heroku: @heroku, string_reference: @context_app, related_apps: related_apps)
  @database = HerokuSchemas::CurrentDatabase.connect_to_url(@schema.database_url)
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



3
4
5
# File 'lib/heroku-schemas/drop.rb', line 3

def database
  @database
end

Instance Method Details

#performObject



17
18
19
20
# File 'lib/heroku-schemas/drop.rb', line 17

def perform
  @database.execute("DROP SCHEMA #{@schema.schema} CASCADE")
  write "Dropped schema #{@schema.database_app}:#{@schema.database_variable}:#{@schema.schema}"
end