Fix post deployment migrations for Geo database

parent 080e52e0
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
# before other initializers as Rails may otherwise memoize a list of migrations # before other initializers as Rails may otherwise memoize a list of migrations
# excluding the post deployment migrations. # excluding the post deployment migrations.
unless ENV['SKIP_POST_DEPLOYMENT_MIGRATIONS'] unless ENV['SKIP_POST_DEPLOYMENT_MIGRATIONS']
path = Rails.root.join('db', 'post_migrate').to_s Rails.application.config.paths['db'].each do |db_path|
path = Rails.root.join(db_path, 'post_migrate').to_s
Rails.application.config.paths['db/migrate'] << path Rails.application.config.paths['db/migrate'] << path
# Rails memoizes migrations at certain points where it won't read the above # Rails memoizes migrations at certain points where it won't read the above
# path just yet. As such we must also update the following list of paths. # path just yet. As such we must also update the following list of paths.
ActiveRecord::Migrator.migrations_paths << path ActiveRecord::Migrator.migrations_paths << path
end
end end
...@@ -55,13 +55,11 @@ namespace :geo do ...@@ -55,13 +55,11 @@ namespace :geo do
# save current configuration # save current configuration
@previous_config = { @previous_config = {
config: Rails.application.config.dup, config: Rails.application.config.dup,
schema: ENV['SCHEMA'], schema: ENV['SCHEMA']
skip_post_deployment_migrations: ENV['SKIP_POST_DEPLOYMENT_MIGRATIONS']
} }
# set config variables for geo database # set config variables for geo database
ENV['SCHEMA'] = 'db/geo/schema.rb' ENV['SCHEMA'] = 'db/geo/schema.rb'
ENV['SKIP_POST_DEPLOYMENT_MIGRATIONS'] = 'true'
Rails.application.config.paths['db'] = ['db/geo'] Rails.application.config.paths['db'] = ['db/geo']
Rails.application.config.paths['db/migrate'] = ['db/geo/migrate'] Rails.application.config.paths['db/migrate'] = ['db/geo/migrate']
Rails.application.config.paths['db/seeds.rb'] = ['db/geo/seeds.rb'] Rails.application.config.paths['db/seeds.rb'] = ['db/geo/seeds.rb']
...@@ -71,7 +69,6 @@ namespace :geo do ...@@ -71,7 +69,6 @@ namespace :geo do
task :restore do task :restore do
# restore config variables to previous values # restore config variables to previous values
ENV['SCHEMA'] = @previous_config[:schema] ENV['SCHEMA'] = @previous_config[:schema]
ENV['SKIP_POST_DEPLOYMENT_MIGRATIONS'] = @previous_config[:skip_post_deployment_migrations]
Rails.application.config = @previous_config[:config] Rails.application.config = @previous_config[:config]
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment