mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 16:07:17 +08:00
DEV: Upgrade to Rails 7
This patch upgrades Rails to version 7.0.2.4.
This commit is contained in:

committed by
Loïc Guitaut

parent
532f9cdb1a
commit
008b700a3f
@ -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
|
50
lib/freedom_patches/ar_references_fix.rb
Normal file
50
lib/freedom_patches/ar_references_fix.rb
Normal 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
|
@ -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
|
||||
|
Reference in New Issue
Block a user