Skip to content

Commit

Permalink
feat(tests): use unlogged tables with PostgreSQL
Browse files Browse the repository at this point in the history
This seems to somewhat improve testsuite performance.
  • Loading branch information
nijel committed Oct 4, 2024
1 parent a3fa4b4 commit d6101fd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion weblate/settings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"isolation_level": "read committed",
}
elif CI_DATABASE == "postgresql":
DATABASES["default"]["ENGINE"] = "django.db.backends.postgresql"
DATABASES["default"]["ENGINE"] = "weblate.utils.postgres_unlogged"
default_user = "postgres"
else:
if not CI_DATABASE:
Expand Down
Empty file.
12 changes: 12 additions & 0 deletions weblate/utils/postgres_unlogged/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright © Michal Čihař <michal@weblate.org>
#
# SPDX-License-Identifier: GPL-3.0-or-later

from django.db.backends.postgresql.base import * # noqa: F403
from django.db.backends.postgresql.base import DatabaseWrapper as OrigDatabaseWrapper

from .schema import DatabaseSchemaEditor


class DatabaseWrapper(OrigDatabaseWrapper): # type: ignore [no-redef]
SchemaEditorClass = DatabaseSchemaEditor
14 changes: 14 additions & 0 deletions weblate/utils/postgres_unlogged/schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright © Michal Čihař <michal@weblate.org>
#
# SPDX-License-Identifier: GPL-3.0-or-later

from django.db.backends.postgresql.schema import (
DatabaseSchemaEditor as OrigDatabaseSchemaEditorg,
)


class DatabaseSchemaEditor(OrigDatabaseSchemaEditorg):
sql_create_table = OrigDatabaseSchemaEditorg.sql_create_table.replace(
"CREATE TABLE ",
"CREATE UNLOGGED TABLE ",
)

0 comments on commit d6101fd

Please sign in to comment.