DEV: Upgrade to Rails 7

This patch upgrades Rails to version 7.0.2.4.
This commit is contained in:
Loïc Guitaut
2022-03-21 15:28:52 +01:00
committed by Loïc Guitaut
parent 532f9cdb1a
commit 008b700a3f
99 changed files with 724 additions and 691 deletions

View File

@ -1,19 +0,0 @@
# frozen_string_literal: true
# Pulls in https://github.com/rails/rails/pull/42368 early since the query is
# definitely more efficient as it does not involved the PG planner.
# Remove once Rails 7 has been released.
module ActiveRecord
module ConnectionAdapters
class PostgreSQLAdapter
def active?
@lock.synchronize do
@connection.query ";"
end
true
rescue PG::Error
false
end
end
end
end

View File

@ -0,0 +1,50 @@
# frozen_string_literal: true
# This patch is a backport of https://github.com/rails/rails/pull/42350
# It fixes a bug introduced by Rails which affects reference columns marking
# them as integer instead of bigint.
#
# This should be deleted when version 7.0.3 is released.
module FreedomPatches
module ArReferencesFix
module SchemaDefinition
def index_options(table_name)
index_options = as_options(index)
# legacy reference index names are used on versions 6.0 and earlier
return index_options if options[:_uses_legacy_reference_index_name]
index_options[:name] ||= polymorphic_index_name(table_name) if polymorphic
index_options
end
ActiveRecord::ConnectionAdapters::ReferenceDefinition.prepend(self)
end
end
end
class ActiveRecord::Migration::Compatibility::V6_0
module TableDefinition
def references(*args, **options)
options[:_uses_legacy_reference_index_name] = true
super
end
alias :belongs_to :references
end
def add_reference(table_name, ref_name, **options)
if connection.adapter_name == "SQLite"
options[:type] = :integer
end
options[:_uses_legacy_reference_index_name] = true
super
end
alias :add_belongs_to :add_reference
def compatible_table_definition(t)
class << t
prepend TableDefinition
end
super
end
end

View File

@ -10,7 +10,7 @@ module RailsMultisite
break if !defined?(RailsFailover::ActiveRecord)
break if db == RailsMultisite::ConnectionManagement::DEFAULT
reading_role = :"#{db}_#{ActiveRecord::Base.reading_role}"
reading_role = :"#{db}_#{ActiveRecord.reading_role}"
spec = RailsMultisite::ConnectionManagement.connection_spec(db: db)
ActiveRecord::Base.connection_handlers[reading_role] ||= begin