From ece23b5fa01301ec006aa42f8b59ec938c35427b Mon Sep 17 00:00:00 2001 From: Seamus Abshere Date: Tue, 4 Sep 2012 18:46:05 -0500 Subject: Use the 'mysql' binary for 'rake db:structure:load'. The previous implementation had the strange requirement that db/structure.sql contain only CREATE TABLE sql statements, one per table, separated by double newlines. SQLite3 and PostgreSQL database tasks, on the other hand, simply spawn 'sqlite3' and 'psql' binaries to load the file directly. The new implementation follows this and attempts to respect all current MySQL configuration settings. --- activerecord/test/cases/tasks/mysql_rake_test.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'activerecord/test/cases/tasks/mysql_rake_test.rb') diff --git a/activerecord/test/cases/tasks/mysql_rake_test.rb b/activerecord/test/cases/tasks/mysql_rake_test.rb index b49561d858..be591da8d6 100644 --- a/activerecord/test/cases/tasks/mysql_rake_test.rb +++ b/activerecord/test/cases/tasks/mysql_rake_test.rb @@ -251,17 +251,14 @@ module ActiveRecord ActiveRecord::Base.stubs(:connection).returns(@connection) ActiveRecord::Base.stubs(:establish_connection).returns(true) + Kernel.stubs(:system) end def test_structure_load filename = "awesome-file.sql" - ActiveRecord::Base.expects(:establish_connection).with(@configuration) - @connection.expects(:execute).twice + Kernel.expects(:system).with('mysql', '--database', 'test-db', '--execute', %{SET FOREIGN_KEY_CHECKS = 0; SOURCE #{filename}; SET FOREIGN_KEY_CHECKS = 1}) - open(filename, 'w') { |f| f.puts("SELECT CURDATE();") } ActiveRecord::Tasks::DatabaseTasks.structure_load(@configuration, filename) - ensure - FileUtils.rm(filename) end end -- cgit v1.2.3