From 46cb1b047d5394ceac77bb4ef417c08ba1c55d1f Mon Sep 17 00:00:00 2001 From: Daniel Ceballos Date: Wed, 5 Jun 2013 12:11:37 -0700 Subject: [PATCH] make schema_migrations run separately for each schema --- lib/roomer/helpers/postgres_helper.rb | 7 ++++++- lib/roomer/schema.rb | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/roomer/helpers/postgres_helper.rb b/lib/roomer/helpers/postgres_helper.rb index 032b305..e2cd765 100644 --- a/lib/roomer/helpers/postgres_helper.rb +++ b/lib/roomer/helpers/postgres_helper.rb @@ -108,7 +108,12 @@ def create_sequence(table_name, pk="id") # Ensures schema_migrations table exists and creates otherwise # @see ActiveRecord::Base.connection#initialize_schema_migrations_table def ensure_schema_migrations - ActiveRecord::Base.connection.initialize_schema_migrations_table + old_search_path = ActiveRecord::Base.connection.schema_search_path + old_search_path.split(",").each do |search_path| + ActiveRecord::Base.connection.schema_search_path = search_path + ActiveRecord::Base.connection.initialize_schema_migrations_table + end + ActiveRecord::Base.connection.schema_search_path = old_search_path end # Determine if there are any pending migrations in the shared migrations directory diff --git a/lib/roomer/schema.rb b/lib/roomer/schema.rb index 70f3c08..9d5b006 100644 --- a/lib/roomer/schema.rb +++ b/lib/roomer/schema.rb @@ -61,7 +61,6 @@ def self.define(info={}, &block) end def self.current_schema - $stderr.puts "current search path is #{ActiveRecord::Base.connection.schema_search_path}" ActiveRecord::Base.connection.schema_search_path.split(",")[0] end