Skip to content

Commit 6f981b7

Browse files
committed
better logging
1 parent 7f99376 commit 6f981b7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pum/schema_migrations.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def __init__(self, config: PumConfig) -> None:
3737
psycopg.sql.Identifier(MIGRATION_TABLE_NAME),
3838
]
3939
)
40+
self.migration_table_identifier_str = (
41+
f"{self.config.config.pum.migration_table_schema}.{MIGRATION_TABLE_NAME}"
42+
)
4043

4144
def exists(self, connection: psycopg.Connection) -> bool:
4245
"""Check if the schema_migrations information table exists.
@@ -150,7 +153,7 @@ def create(
150153
SqlContent(create_table_query).execute(connection, parameters=parameters)
151154
SqlContent(comment_query).execute(connection, parameters=parameters)
152155

153-
logger.info(f"Created {parameters['schema']}.{parameters['table']} table")
156+
logger.info(f"Created migration table: {self.migration_table_identifier_str}")
154157

155158
if commit:
156159
connection.commit()
@@ -220,7 +223,7 @@ def set_baseline(
220223
}
221224

222225
logger.info(
223-
f"Setting baseline version {version} in {self.config.config.pum.migration_table_schema}.{MIGRATION_TABLE_NAME} table"
226+
f"Setting baseline version {version} in {self.migration_table_identifier_str} table"
224227
)
225228
SqlContent(code).execute(connection, parameters=query_parameters, commit=commit)
226229

@@ -255,7 +258,7 @@ def baseline(self, connection: psycopg.Connection) -> packaging.version.Version:
255258

256259
if not self.exists(connection=connection):
257260
raise PumSchemaMigrationError(
258-
f"{self.config.config.pum.migration_table_schema}.pum_migrations table does not exist."
261+
f"{self.migration_table_identifier_str} table does not exist."
259262
)
260263

261264
query = psycopg.sql.SQL(
@@ -279,7 +282,7 @@ def baseline(self, connection: psycopg.Connection) -> packaging.version.Version:
279282
row = cursor.fetchone()
280283
if row is None:
281284
raise PumSchemaMigrationNoBaselineError(
282-
"Baseline version not found in the migration table."
285+
f"Baseline version not found in the {self.migration_table_identifier_str} table."
283286
)
284287
return packaging.version.parse(row[0])
285288

@@ -335,7 +338,9 @@ def migration_details(self, connection: psycopg.Connection, version: str | None
335338
cursor = SqlContent(query).execute(connection, parameters=parameters)
336339
row = cursor.fetchone()
337340
if row is None:
338-
raise PumSchemaMigrationError(f"Migration details not found for version {version}.")
341+
raise PumSchemaMigrationError(
342+
f"Migration details not found for version {version} in the {self.migration_table_identifier_str} table."
343+
)
339344
return dict(zip([desc[0] for desc in cursor.description], row, strict=False))
340345

341346
def compare(self, connection: psycopg.Connection) -> int:

0 commit comments

Comments
 (0)