mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Respect ignore_tables
in Postgres structure dump
When using `sql` as the schema format, or even just doing `rake db:structure:dump`, it would be good to respect the list of ignored tables that has been configured.
This commit is contained in:
parent
7cc526beb5
commit
be1dd45200
2 changed files with 14 additions and 0 deletions
|
@ -66,6 +66,12 @@ module ActiveRecord
|
|||
"--schema=#{part.strip}"
|
||||
end
|
||||
end
|
||||
|
||||
ignore_tables = ActiveRecord::SchemaDumper.ignore_tables
|
||||
if ignore_tables.any?
|
||||
args += ignore_tables.flat_map { |table| ["-T", table] }
|
||||
end
|
||||
|
||||
args << configuration["database"]
|
||||
run_cmd("pg_dump", args, "dumping")
|
||||
remove_sql_header_comments(filename)
|
||||
|
|
|
@ -259,6 +259,14 @@ if current_adapter?(:PostgreSQLAdapter)
|
|||
end
|
||||
end
|
||||
|
||||
def test_structure_dump_with_ignore_tables
|
||||
ActiveRecord::SchemaDumper.expects(:ignore_tables).returns(["foo", "bar"])
|
||||
|
||||
Kernel.expects(:system).with("pg_dump", "-s", "-x", "-O", "-f", @filename, "-T", "foo", "-T", "bar", "my-app-db").returns(true)
|
||||
|
||||
ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, @filename)
|
||||
end
|
||||
|
||||
def test_structure_dump_with_schema_search_path
|
||||
@configuration["schema_search_path"] = "foo,bar"
|
||||
|
||||
|
|
Loading…
Reference in a new issue