DEV: Create unlogged tables by default in the test environment (#25451)

Why this change?

In https://www.postgresql.org/docs/current/non-durability.html, it is
recommended to create unlogged tables to avoid WAL writes which can help
speed at performance at the expense of durability. In the CI env, there is no need for durability at all.
Therefore, we are going to be creating unlogged tables by default.

Co-authored-by: Ted Johansson <ted@discourse.org>
Co-authored-by: Rafael dos Santos Silva <xfalcox@gmail.com>
This commit is contained in:
Alan Guo Xiang Tan 2024-01-29 09:57:58 +08:00 committed by GitHub
parent c7860173c1
commit 18d652c8f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -145,6 +145,7 @@ jobs:
${{ runner.os }}-
${{ hashFiles('.github/workflows/tests.yml') }}-
${{ hashFiles('db/**/*', 'plugins/**/db/**/*') }}-
${{ hashFiles('config/environments/test.rb') }}-
${{ env.USES_PARALLEL_DATABASES }}
- name: Restore database from cache

View File

@ -104,4 +104,10 @@ Discourse::Application.configure do
SiteSetting.refresh!
end
if ENV["CI"].present?
config.to_prepare do
ActiveSupport.on_load(:active_record_postgresqladapter) { self.create_unlogged_tables = true }
end
end
end