Skip to content

Commit

Permalink
Merge pull request #22886 from jrafanie/legacy_binds_support_dropped_…
Browse files Browse the repository at this point in the history
…in_rails7

Passing legacy binds was deprecated in 6.1 and removed in 7.
  • Loading branch information
Fryguy authored Feb 7, 2024
2 parents 29f332f + 74c7a32 commit 6401cf1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/extensions/ar_migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@ def self.update_local_migrations_ran(version, direction)
end

to_add.each do |v|
ActiveRecord::Base.connection.exec_insert("INSERT INTO schema_migrations_ran (version, created_at) VALUES ($1, $2)", "SQL", [[nil, v], [nil, Time.now.utc.iso8601(6)]])
binds = [
ActiveRecord::Relation::QueryAttribute.new("version", v, ActiveModel::Type::String.new),
ActiveRecord::Relation::QueryAttribute.new("created_at", Time.now.utc.iso8601(6), ActiveModel::Type::Value.new)
]
ActiveRecord::Base.connection.exec_insert("INSERT INTO schema_migrations_ran (version, created_at) VALUES ($1, $2)", "SQL", binds, nil, nil)
end
else
ActiveRecord::Base.connection.exec_delete("DELETE FROM schema_migrations_ran WHERE version = $1", "SQL", [[nil, version]])
binds = [ActiveRecord::Relation::QueryAttribute.new("version", version, ActiveModel::Type::String.new)]
ActiveRecord::Base.connection.exec_delete("DELETE FROM schema_migrations_ran WHERE version = $1", "SQL", binds)
end
end

Expand Down

0 comments on commit 6401cf1

Please sign in to comment.