Skip to content

Commit

Permalink
Small change to template database initialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
fizyk committed Mar 11, 2024
1 parent 68a3504 commit 4b4aa95
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions pytest_postgresql/janitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ def init(self) -> None:
"""Create database in postgresql."""
with self.cursor() as cur:
if self.is_template():
cur.execute(f'CREATE DATABASE "{self.template_dbname}";')
cur.execute(f'ALTER DATABASE "{self.template_dbname}" with is_template true;')
cur.execute(f'CREATE DATABASE "{self.template_dbname}" WITH is_template = true;')
elif self.template_dbname is None:
cur.execute(f'CREATE DATABASE "{self.dbname}";')
else:
Expand All @@ -90,8 +89,6 @@ def drop(self) -> None:
with self.cursor() as cur:
self._dont_datallowconn(cur, db_to_drop)
self._terminate_connection(cur, db_to_drop)
if self.is_template():
cur.execute(f'ALTER DATABASE "{db_to_drop}" with is_template false;')
cur.execute(f'DROP DATABASE IF EXISTS "{db_to_drop}";')

@staticmethod
Expand Down

0 comments on commit 4b4aa95

Please sign in to comment.