diff --git a/lib/lazy_migrate/client.rb b/lib/lazy_migrate/client.rb index 0056018..031fe3f 100644 --- a/lib/lazy_migrate/client.rb +++ b/lib/lazy_migrate/client.rb @@ -22,9 +22,13 @@ def run loop do catch(:done) do on_done = -> { throw :done } + database_name = if ActiveRecord::Base.respond_to?(:connection_db_config) + ActiveRecord::Base.connection_db_config.database # Rails 7 + else + ActiveRecord::Base.connection_config[:database] # Rails 6- + end - prompt.ok("\nDatabase: #{ActiveRecord::Base.connection_config[:database]}\n") - + prompt.ok("\nDatabase: #{database_name}\n") select_migration_prompt(on_done: on_done, migrator_adapter: migrator_adapter) end end diff --git a/lib/lazy_migrate/migrator_adapter.rb b/lib/lazy_migrate/migrator_adapter.rb index b48545d..8abbcaf 100644 --- a/lib/lazy_migrate/migrator_adapter.rb +++ b/lib/lazy_migrate/migrator_adapter.rb @@ -58,7 +58,7 @@ def replace_version_in_filename(filename, new_version) sig { void } def dump_schema - return if !ActiveRecord::Base.dump_schema_after_migration + return if !ActiveRecord.dump_schema_after_migration # ripped from https://github.com/rails/rails/blob/5-1-stable/activerecord/lib/active_record/railties/databases.rake filename = ENV["SCHEMA"] || File.join(ActiveRecord::Tasks::DatabaseTasks.db_dir, "schema.rb")