diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-06-15 19:50:05 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-06-15 19:50:05 +0900 |
commit | 28b54c6b479dde42d08dbfd9faa2e5fbfcadf86f (patch) | |
tree | 10dd069963086f8cb279f75061dcc469edd3782c /activerecord | |
parent | d9496c19c07d56bb200acd7312bf5d6355d515f4 (diff) | |
download | rails-28b54c6b479dde42d08dbfd9faa2e5fbfcadf86f.tar.gz rails-28b54c6b479dde42d08dbfd9faa2e5fbfcadf86f.tar.bz2 rails-28b54c6b479dde42d08dbfd9faa2e5fbfcadf86f.zip |
Fix `dump_schema_information` with empty versions
Fixes #29460.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/schema_dumper_test.rb | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index a1031ccbf5..22d7791dec 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -1010,7 +1010,7 @@ module ActiveRecord def dump_schema_information #:nodoc: versions = ActiveRecord::SchemaMigration.all_versions - insert_versions_sql(versions) + insert_versions_sql(versions) if versions.any? end def initialize_schema_migrations_table # :nodoc: diff --git a/activerecord/test/cases/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb index b5386ba801..4c81e825fa 100644 --- a/activerecord/test/cases/schema_dumper_test.rb +++ b/activerecord/test/cases/schema_dumper_test.rb @@ -17,6 +17,12 @@ class SchemaDumperTest < ActiveRecord::TestCase dump_all_table_schema [] end + def test_dump_schema_information_with_empty_versions + ActiveRecord::SchemaMigration.delete_all + schema_info = ActiveRecord::Base.connection.dump_schema_information + assert_no_match(/INSERT INTO/, schema_info) + end + def test_dump_schema_information_outputs_lexically_ordered_versions versions = %w{ 20100101010101 20100201010101 20100301010101 } versions.reverse_each do |v| |