Hooking `db:load_config` worked in v5 but not in v6

Hey all!

I have a v5.2 project that I used the below code from this SO to run all my migrations as the base_user even if the migrations happened via another connected user.

Another project, now Rails v6, I did the same exact thing but unlike in v5, the migrations still ran under the connected userscontext instead ofbase_user. I.e. the SET ROLE base_user` didn’t seem to “stick” like it did in v5.

I know a lot changed vis-a-vis connections to the DB in that major version jump, but is there still a way to accomplish what I’d like to in Rails v6?

# lib/tasks/migration_hooks.rake

namespace :db do
  task set_role_postgres: :environment do
    ActiveRecord::Base.connection.execute('SET ROLE base_user')
  end
end

Rake::Task['db:load_config'].enhance ['db:set_role_postgres']