Permalink
Browse files

Respect 'ignore_tables' in MySQL structure dump

  • Loading branch information...
guilleiguaran committed May 14, 2017
1 parent be1dd45 commit 486562fa955f2cbd574e7f4099fdf69a49a8ce20
@@ -60,6 +60,12 @@ def structure_dump(filename, extra_flags)
args.concat(["--routines"])
args.concat(["--skip-comments"])
args.concat(Array(extra_flags)) if extra_flags
ignore_tables = ActiveRecord::SchemaDumper.ignore_tables
if ignore_tables.any?
args += ignore_tables.map { |table| "--ignore-table=#{configuration['database']}.#{table}" }
end
args.concat(["#{configuration['database']}"])
run_cmd("mysqldump", args, "dumping")
@@ -294,6 +294,13 @@ def test_structure_dump
ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, filename)
end
def test_structure_dump
filename = "awesome-file.sql"
Kernel.expects(:system).with("mysqldump", "--result-file", filename, "--no-data", "--routines", "--skip-comments", "test-db").returns(true)
ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, filename)
end
def test_structure_dump_with_extra_flags
filename = "awesome-file.sql"
expected_command = ["mysqldump", "--result-file", filename, "--no-data", "--routines", "--skip-comments", "--noop", "test-db"]
@@ -305,6 +312,15 @@ def test_structure_dump_with_extra_flags
end
end
def test_structure_dump_with_ignore_tables
filename = "awesome-file.sql"
ActiveRecord::SchemaDumper.expects(:ignore_tables).returns(["foo", "bar"])
Kernel.expects(:system).with("mysqldump", "--result-file", filename, "--no-data", "--routines", "--skip-comments", "--ignore-table=test-db.foo", "--ignore-table=test-db.bar", "test-db").returns(true)
ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, filename)
end
def test_warn_when_external_structure_dump_command_execution_fails
filename = "awesome-file.sql"
Kernel.expects(:system)

0 comments on commit 486562f

Please sign in to comment.