Skip to content

Commit

Permalink
Dropped support for Ruby < 3.1 and Rails < 6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Jun 17, 2024
1 parent c9d82e2 commit 63f889c
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 30 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ jobs:
- ruby: 3.3
gemfile: gemfiles/activerecord72.gemfile
postgres: 16
- ruby: 3.2
- ruby: 3.3
gemfile: Gemfile
postgres: 15
- ruby: 3.1
gemfile: gemfiles/activerecord70.gemfile
postgres: 14
- ruby: "3.0"
gemfile: gemfiles/activerecord61.gemfile
- ruby: 3.2
gemfile: gemfiles/activerecord70.gemfile
postgres: 12
- ruby: 2.7
gemfile: gemfiles/activerecord60.gemfile
- ruby: 3.1
gemfile: gemfiles/activerecord61.gemfile
postgres: 10
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.6.0 (unreleased)

- Dropped support for Ruby < 3.1 and Rails < 6.1

## 3.5.0 (2024-05-21)

- Added materialized views to space page and `relation_sizes` method
Expand Down
12 changes: 0 additions & 12 deletions gemfiles/activerecord60.gemfile

This file was deleted.

6 changes: 2 additions & 4 deletions lib/pghero.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,12 @@ def clean_space_stats(before: nil)

# private
def connection_config(model)
ActiveRecord::VERSION::STRING.to_f >= 6.1 ? model.connection_db_config.configuration_hash : model.connection_config
model.connection_db_config.configuration_hash
end

# private
# Rails 6.1 deprecates `spec_name` for `name`
# https://github.com/rails/rails/pull/38536
def spec_name_key
ActiveRecord::VERSION::STRING.to_f >= 6.1 ? :name : :spec_name
:name
end

# private
Expand Down
2 changes: 1 addition & 1 deletion lib/pghero/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def build_connection_model
config_options = {env_name: PgHero.env, PgHero.spec_name_key => config["spec"], PgHero.include_replicas_key => true}
resolved = ActiveRecord::Base.configurations.configs_for(**config_options)
raise Error, "Spec not found: #{config["spec"]}" unless resolved
url = ActiveRecord::VERSION::STRING.to_f >= 6.1 ? resolved.configuration_hash : resolved.config
url = resolved.configuration_hash
end

url = url.dup
Expand Down
4 changes: 1 addition & 3 deletions lib/pghero/methods/basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ def select_all(sql, conn: nil, query_columns: [])
result = conn.select_all(add_source(squish(sql)))
if ActiveRecord::VERSION::MAJOR >= 8
result = result.to_a.map(&:symbolize_keys)
elsif ActiveRecord::VERSION::STRING.to_f >= 6.1
result = result.map(&:symbolize_keys)
else
result = result.map { |row| row.to_h { |col, val| [col.to_sym, result.column_types[col].send(:cast_value, val)] } }
result = result.map(&:symbolize_keys)
end
if filter_data
query_columns.each do |column|
Expand Down
4 changes: 2 additions & 2 deletions pghero.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
spec.files = Dir["*.{md,txt}", "{app,config,lib,licenses}/**/*"]
spec.require_path = "lib"

spec.required_ruby_version = ">= 2.7"
spec.required_ruby_version = ">= 3.1"

spec.add_dependency "activerecord", ">= 6"
spec.add_dependency "activerecord", ">= 6.1"
end

0 comments on commit 63f889c

Please sign in to comment.