Skip to content

Instantly share code, notes, and snippets.

@codertcet111
Created April 21, 2023 06:55
Show Gist options
  • Select an option

  • Save codertcet111/d5fed6d554d8ac2da1febeeaaf67cbb1 to your computer and use it in GitHub Desktop.

Select an option

Save codertcet111/d5fed6d554d8ac2da1febeeaaf67cbb1 to your computer and use it in GitHub Desktop.
if ActiveRecord::Base.connection_config[:adapter] == 'postgresql'
ActiveRecord::Base.connection.execute("SET statement_timeout = '10000';") # 10 seconds
# Register an before migration callback to reset the timeout to 0 which means no timeout
ActiveRecord::Migration.before_migrate do
ActiveRecord::Base.connection.execute("SET statement_timeout = '0';")
end
ActiveRecord::Migration.after_migrate do
ActiveRecord::Base.connection.execute("SET statement_timeout = '10000';")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment