-
-
Save MaherSaif/2f051169406f7b33cb15ccd5550af217 to your computer and use it in GitHub Desktop.
speed up testsuit by using unlogged tables in PG
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
# config/environments/test.rb | |
ActiveSupport.on_load(:active_record_postgresqladapter) do | |
# For this optimization to work, you need to recreate your test database | |
self.create_unlogged_tables = true | |
end |
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
# Run `RAILS_ENV=test rails c` | |
puts ActiveRecord::Base.connection.execute("SELECT relpersistence FROM pg_class WHERE relname = 'users'").first | |
# In case table is unlogged following will be returned: | |
# {"relpersistence"=>"u"} | |
# In case table is regular, following will be returned: | |
#{"relpersistence"=>"p"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment