Report PostgreSQL collation drift in live smoke
This commit is contained in:
@@ -69,6 +69,26 @@ required_objects = [
|
||||
with get_engine().connect() as connection:
|
||||
postgis_version = connection.execute(text("SELECT PostGIS_Version()")).scalar()
|
||||
print(f"PostGIS version: {postgis_version}")
|
||||
collation_row = connection.execute(
|
||||
text(
|
||||
"SELECT datname, datcollversion, pg_database_collation_actual_version(oid) AS actual_version "
|
||||
"FROM pg_database WHERE datname = current_database()"
|
||||
)
|
||||
).mappings().one()
|
||||
stored_version = collation_row["datcollversion"]
|
||||
actual_version = collation_row["actual_version"]
|
||||
if stored_version != actual_version:
|
||||
database_name = str(collation_row["datname"]).replace('"', '""')
|
||||
print(
|
||||
"COLLATION_VERSION_MISMATCH: "
|
||||
f"database={collation_row['datname']} stored={stored_version} actual={actual_version}"
|
||||
)
|
||||
print(
|
||||
"After reviewing backups and indexes, acknowledge with: "
|
||||
f'ALTER DATABASE "{database_name}" REFRESH COLLATION VERSION;'
|
||||
)
|
||||
else:
|
||||
print("Database collation version: ok")
|
||||
|
||||
missing = [
|
||||
object_name
|
||||
@@ -154,6 +174,26 @@ required_objects = [
|
||||
with get_engine().connect() as connection:
|
||||
postgis_version = connection.execute(text("SELECT PostGIS_Version()")).scalar()
|
||||
print(f"PostGIS version: {postgis_version}")
|
||||
collation_row = connection.execute(
|
||||
text(
|
||||
"SELECT datname, datcollversion, pg_database_collation_actual_version(oid) AS actual_version "
|
||||
"FROM pg_database WHERE datname = current_database()"
|
||||
)
|
||||
).mappings().one()
|
||||
stored_version = collation_row["datcollversion"]
|
||||
actual_version = collation_row["actual_version"]
|
||||
if stored_version != actual_version:
|
||||
database_name = str(collation_row["datname"]).replace('"', '""')
|
||||
print(
|
||||
"COLLATION_VERSION_MISMATCH: "
|
||||
f"database={collation_row['datname']} stored={stored_version} actual={actual_version}"
|
||||
)
|
||||
print(
|
||||
"After reviewing backups and indexes, acknowledge with: "
|
||||
f'ALTER DATABASE "{database_name}" REFRESH COLLATION VERSION;'
|
||||
)
|
||||
else:
|
||||
print("Database collation version: ok")
|
||||
|
||||
missing = [
|
||||
object_name
|
||||
@@ -267,6 +307,26 @@ required_objects = [
|
||||
with get_engine().connect() as connection:
|
||||
postgis_version = connection.execute(text("SELECT PostGIS_Version()")).scalar()
|
||||
print(f"PostGIS version: {postgis_version}")
|
||||
collation_row = connection.execute(
|
||||
text(
|
||||
"SELECT datname, datcollversion, pg_database_collation_actual_version(oid) AS actual_version "
|
||||
"FROM pg_database WHERE datname = current_database()"
|
||||
)
|
||||
).mappings().one()
|
||||
stored_version = collation_row["datcollversion"]
|
||||
actual_version = collation_row["actual_version"]
|
||||
if stored_version != actual_version:
|
||||
database_name = str(collation_row["datname"]).replace('"', '""')
|
||||
print(
|
||||
"COLLATION_VERSION_MISMATCH: "
|
||||
f"database={collation_row['datname']} stored={stored_version} actual={actual_version}"
|
||||
)
|
||||
print(
|
||||
"After reviewing backups and indexes, acknowledge with: "
|
||||
f'ALTER DATABASE "{database_name}" REFRESH COLLATION VERSION;'
|
||||
)
|
||||
else:
|
||||
print("Database collation version: ok")
|
||||
|
||||
missing = [
|
||||
object_name
|
||||
|
||||
Reference in New Issue
Block a user