lib/tasks/switchman.rake in switchman-3.0.5 vs lib/tasks/switchman.rake in switchman-3.0.6
- old
+ new
@@ -44,11 +44,11 @@
scope
end
def self.options
- { parallel: ENV['PARALLEL'].to_i, max_procs: ENV['MAX_PARALLEL_PROCS'] }
+ { parallel: ENV['PARALLEL'].to_i }
end
# classes - an array or proc, to activate as the current shard during the
# task. tasks which modify the schema may want to pass all categories in
# so that schema updates for non-default tables happen against all shards.
@@ -78,18 +78,18 @@
end
rescue => e
puts "Exception from #{e.current_shard.id}: #{e.current_shard.description}" if options[:parallel] != 0
raise
- #::ActiveRecord::Base.configurations = old_configurations
+ # ::ActiveRecord::Base.configurations = old_configurations
end
end
end
end
%w[db:migrate db:migrate:up db:migrate:down db:rollback].each do |task_name|
- shardify_task(task_name, classes: -> { Shard.sharded_models })
+ shardify_task(task_name)
end
def self.shard_scope(scope, raw_shard_ids)
raw_shard_ids = raw_shard_ids.split(',')
@@ -199,17 +199,21 @@
module ActiveRecord
module PostgreSQLDatabaseTasks
def structure_dump(filename, extra_flags = nil)
set_psql_env
- args = ['-s', '-x', '-O', '-f', filename]
+ args = ['--schema-only', '--no-privileges', '--no-owner', '--file', filename]
args.concat(Array(extra_flags)) if extra_flags
shard = Shard.current.name
serialized_search_path = shard
args << "--schema=#{Shellwords.escape(shard)}"
- args << configuration['database']
+ ignore_tables = ::ActiveRecord::SchemaDumper.ignore_tables
+ args += ignore_tables.flat_map { |table| ['-T', table] } if ignore_tables.any?
+
+ args << db_config.database
run_cmd('pg_dump', args, 'dumping')
+ remove_sql_header_comments(filename)
File.open(filename, 'a') { |f| f << "SET search_path TO #{serialized_search_path};\n\n" }
end
end
end
end