aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@users.noreply.github.com>2017-07-22 11:04:52 -0400
committerGitHub <noreply@github.com>2017-07-22 11:04:52 -0400
commit36a301a90aaea213caa54cf3825d3fc9b345c04e (patch)
treeb14b474582113bd749c54748404e5ad0fb4c4d1d
parentc1972c264074211fe77cd61cc06bf04ddadf5277 (diff)
parent8dca921987d9cfcbe6e29f3b164fb7bf08cde3ff (diff)
downloadrails-36a301a90aaea213caa54cf3825d3fc9b345c04e.tar.gz
rails-36a301a90aaea213caa54cf3825d3fc9b345c04e.tar.bz2
rails-36a301a90aaea213caa54cf3825d3fc9b345c04e.zip
Merge pull request #29768 from janpieper/sort-enabled-extensions-in-dump
Sort enabled adapter extensions in schema dump
-rw-r--r--activerecord/lib/active_record/schema_dumper.rb2
-rw-r--r--activerecord/test/cases/schema_dumper_test.rb14
2 files changed, 15 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb
index dd8442a34f..27a1c89bd1 100644
--- a/activerecord/lib/active_record/schema_dumper.rb
+++ b/activerecord/lib/active_record/schema_dumper.rb
@@ -87,7 +87,7 @@ HEADER
extensions = @connection.extensions
if extensions.any?
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}"
end
stream.puts
diff --git a/activerecord/test/cases/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb
index 194fceb0f3..01ec3e06ad 100644
--- a/activerecord/test/cases/schema_dumper_test.rb
+++ b/activerecord/test/cases/schema_dumper_test.rb
@@ -303,6 +303,20 @@ class SchemaDumperTest < ActiveRecord::TestCase
assert_no_match "# These are extensions that must be enabled", output
assert_no_match %r{enable_extension}, output
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