mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Sort enabled adapter extensions in schema dump
The list of enabled adapter extensions in the schema dump isn't sorted by default, so it may happen that the sorting changes over time. If you're using a VCS, a change to the sorting results in a diff without any real change. Sorting the list should solve this problem.
This commit is contained in:
parent
58f10a31b3
commit
8dca921987
2 changed files with 15 additions and 1 deletions
|
@ -85,7 +85,7 @@ HEADER
|
||||||
extensions = @connection.extensions
|
extensions = @connection.extensions
|
||||||
if extensions.any?
|
if extensions.any?
|
||||||
stream.puts " # These are extensions that must be enabled in order to support this database"
|
stream.puts " # These are extensions that must be enabled in order to support this database"
|
||||||
extensions.each do |extension|
|
extensions.sort.each do |extension|
|
||||||
stream.puts " enable_extension #{extension.inspect}"
|
stream.puts " enable_extension #{extension.inspect}"
|
||||||
end
|
end
|
||||||
stream.puts
|
stream.puts
|
||||||
|
|
|
@ -301,6 +301,20 @@ class SchemaDumperTest < ActiveRecord::TestCase
|
||||||
assert_no_match "# These are extensions that must be enabled", output
|
assert_no_match "# These are extensions that must be enabled", output
|
||||||
assert_no_match %r{enable_extension}, output
|
assert_no_match %r{enable_extension}, output
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_schema_dump_includes_extensions_in_alphabetic_order
|
||||||
|
connection = ActiveRecord::Base.connection
|
||||||
|
|
||||||
|
connection.stubs(:extensions).returns(["hstore", "uuid-ossp", "xml2"])
|
||||||
|
output = perform_schema_dump
|
||||||
|
enabled_extensions = output.scan(%r{enable_extension "(.+)"}).flatten
|
||||||
|
assert_equal ["hstore", "uuid-ossp", "xml2"], enabled_extensions
|
||||||
|
|
||||||
|
connection.stubs(:extensions).returns(["uuid-ossp", "xml2", "hstore"])
|
||||||
|
output = perform_schema_dump
|
||||||
|
enabled_extensions = output.scan(%r{enable_extension "(.+)"}).flatten
|
||||||
|
assert_equal ["hstore", "uuid-ossp", "xml2"], enabled_extensions
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue