Class: Migrate

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

Class Method Summary collapse

Class Method Details

.on_schema(schema) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/migrate.rb', line 4

def self.on_schema(schema)
  conn = ActiveRecord::Base.connection

  default_search_path = conn.execute("SHOW search_path").first["search_path"]

  schema_search_path = [schema, SchemaUtils.persistent_schemas].flatten.map(&:inspect).join(", ")

  # Set the custom schema
  conn.execute("SET search_path TO #{schema_search_path}")

  # Execute migration block
  yield

  # Return to default schema path
  conn.execute("SET search_path TO #{default_search_path}")
end