Skip to content

Commit f060bdc

Browse files
committed
fixtures: use unlogged tables for PostgreSQL
1 parent 8c92458 commit f060bdc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pytest_invenio/fixtures.py

+13
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,19 @@ def database(appctx):
466466

467467
if not database_exists(str(db_.engine.url)):
468468
create_database(str(db_.engine.url))
469+
470+
# Use unlogged tables for PostgreSQL
471+
if db_.engine.name == "postgresql":
472+
from sqlalchemy.ext.compiler import compiles
473+
from sqlalchemy.schema import CreateTable
474+
475+
@compiles(CreateTable)
476+
def _compile_unlogged(element, compiler, **kwargs):
477+
return compiler.visit_create_table(element).replace(
478+
"CREATE TABLE ",
479+
"CREATE UNLOGGED TABLE ",
480+
)
481+
469482
db_.create_all()
470483

471484
yield db_

0 commit comments

Comments
 (0)