MVCE: https://github.com/joshleblanc/sharding-migrations-bug
Steps to reproduce
Create a new rails application
Create a sharded database with
# database.yml
development:
default:
database: default
archive:
database: archive
# application_record.rb
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
connects_to shards: {
default: {writing: :default, reading: :default},
archive: {writing: :archive, reading: :archive}
}
end
Create any model, then add a second migration that queries the database using the model, then runs an execute statement.
class ThisShouldBreak < ActiveRecord::Migration[6.0]
def up
Author.count
execute "SELECT * from authors"
end
def down
# no-op
end
end
Expected behavior
The migration should run
Actual behavior
The connection is closed during the migration, triggering a rollback.
System configuration
Rails version: Rails 6.1.3.1
Ruby version: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x64-mingw32]
MVCE: https://github.com/joshleblanc/sharding-migrations-bug
Steps to reproduce
Create a new rails application
Create a sharded database with
Create any model, then add a second migration that queries the database using the model, then runs an
executestatement.Expected behavior
The migration should run
Actual behavior
The connection is closed during the migration, triggering a rollback.
System configuration
Rails version: Rails 6.1.3.1
Ruby version: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x64-mingw32]