lib/tasks/databases.rake in yam-db-charmer-1.7.4.0 vs lib/tasks/databases.rake in yam-db-charmer-1.7.4.8

- old
+ new

@@ -87,10 +87,14 @@ end # find all schema sharded databases and drop them def drop_schema_shard_databases(config) exit unless Rails.env=='test' + + DbCharmer.env = 'test' + DbCharmer::ConnectionFactory.reset! + config.each do |name, sub_config| next unless sub_config.is_a?(Hash) next unless sub_config['database'] # find the database connection for the schema admin db @@ -99,10 +103,17 @@ next unless connection # itereate through entries in the shards_info table to find the # databases that will be dropped dbgm = DbCharmer::Sharding::Method::DbBlockSchemaMap.new(connection.config) - dbgm.drop_all_shard_databases + + # Rescue this as there may not be any tables in the admin db yet + begin + dbgm.drop_all_shard_databases + rescue ActiveRecord::StatementInvalid => e + end + + dbgm.connection.disconnect! # or subsequent rake tasks may fail end end