Class: MultitenancyTools::SchemaDestroyer

Inherits:
Object
  • Object
show all
Defined in:
lib/multitenancy_tools/schema_destroyer.rb

Overview

SchemaDestroyer can be used to destroy a PostgreSQL schema.

Examples:

destroyer = MultitenancyTools::SchemaDestroyer.new('schema name')
destroyer.destroy

Instance Method Summary collapse

Constructor Details

#initialize(schema, connection = ActiveRecord::Base.connection) ⇒ SchemaDestroyer

Returns a new instance of SchemaDestroyer.

Parameters:

  • schema (String)

    schema name

  • connection (ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) (defaults to: ActiveRecord::Base.connection)

    connection adapter



10
11
12
13
# File 'lib/multitenancy_tools/schema_destroyer.rb', line 10

def initialize(schema, connection = ActiveRecord::Base.connection)
  @connection = connection
  @schema = @connection.quote_table_name(schema)
end

Instance Method Details

#destroyObject

Drops the schema.



16
17
18
# File 'lib/multitenancy_tools/schema_destroyer.rb', line 16

def destroy
  @connection.drop_schema(@schema)
end