Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dump_schema_information with empty versions #29462

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ def foreign_key_options(from_table, to_table, options) # :nodoc:

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:
Expand Down
6 changes: 6 additions & 0 deletions activerecord/test/cases/schema_dumper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ def perform_schema_dump
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|
Expand Down