diff --git a/lib/actual_db_schema/commands/list.rb b/lib/actual_db_schema/commands/list.rb index 3d491b0..a45f644 100644 --- a/lib/actual_db_schema/commands/list.rb +++ b/lib/actual_db_schema/commands/list.rb @@ -19,17 +19,20 @@ def preambule puts "\nPhantom migrations\n\n" puts "Below is a list of irrelevant migrations executed in unmerged branches." puts "To bring your database schema up to date, the migrations marked as \"up\" should be rolled back." - db_config = if ActiveRecord::Base.respond_to?(:connection_db_config) - ActiveRecord::Base.connection_db_config.configuration_hash - else - ActiveRecord::Base.connection_config - end database_path = db_config[:database] puts "\ndatabase: #{database_path}\n\n" puts header.join(" ") puts "-" * separator_width end + def db_config + if ActiveRecord::Base.respond_to?(:connection_db_config) + ActiveRecord::Base.connection_db_config.configuration_hash + else + ActiveRecord::Base.connection_config + end + end + def separator_width header.map(&:length).sum + (header.size - 1) * 2 end