Skip to content

Commit

Permalink
Add support Rails 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
VladislavSokov committed Jun 7, 2024
1 parent 7f29003 commit b97b245
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
strategy:
matrix:
include:
- { ruby: '2.7', rails: '6.0' }
- { ruby: '2.7', rails: '6.1' }
- { ruby: '3.0', rails: '6.1' }
- { ruby: '3.1', rails: '7.0' }
Expand Down
9 changes: 7 additions & 2 deletions lib/actual_db_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ def self.default_migrated_folder
end

def self.migrations_paths
ActiveRecord::Base.connection_db_config.migrations_paths
if ActiveRecord::Base.respond_to?(:connection_db_config)
ActiveRecord::Base.connection_db_config.migrations_paths
else
ActiveRecord::Base.connection_config[:migrations_paths]
end
end

def self.migration_filename(fullpath)
Expand All @@ -60,7 +64,8 @@ def self.migration_filename(fullpath)
def self.for_each_db_connection
configs = ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env)
configs.each do |db_config|
ActiveRecord::Base.establish_connection(db_config)
config = db_config.respond_to?(:config) ? db_config.config : db_config
ActiveRecord::Base.establish_connection(config)
yield
end
end
Expand Down
8 changes: 7 additions & 1 deletion lib/actual_db_schema/commands/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ 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."
puts "\ndatabase: #{ActiveRecord::Base.connection_db_config.database}\n\n"
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
Expand Down
Empty file.

0 comments on commit b97b245

Please sign in to comment.