Created
April 21, 2023 06:55
-
-
Save codertcet111/d5fed6d554d8ac2da1febeeaaf67cbb1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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