diff --git a/faststream_outbox/schema_validation.py b/faststream_outbox/schema_validation.py index 93a2588..055d734 100644 --- a/faststream_outbox/schema_validation.py +++ b/faststream_outbox/schema_validation.py @@ -230,6 +230,9 @@ def _validate_check_constraints_sync(connection: "Connection", table: "Table") - ) +_PENDING_IDX_UPGRADE_URL = "https://faststream-outbox.modern-python.org/operations/alembic/#upgrading-to-015" + + def _compose_schema_mismatch_message(errors: list[str], *, has_blind_drift: bool) -> str: """Build the validate_schema RuntimeError text; append the remediation pointer for Alembic-blind drift.""" msg = _SCHEMA_MISMATCH_PREFIX + "; ".join(errors) @@ -377,5 +380,8 @@ def _drift_entry_to_error(entry: "tuple[typing.Any, ...]", table_name: str) -> s if op == "add_index": idx = entry[1] cols = [c.name for c in idx.columns] - return f"table '{table_name}' missing index over {cols} (name={idx.name!r}, unique={bool(idx.unique)})" + error = f"table '{table_name}' missing index over {cols} (name={idx.name!r}, unique={bool(idx.unique)})" + if idx.name.endswith(_PENDING_IDX_SUFFIX): + error += f"; a table created before 0.15 needs this index rebuilt: {_PENDING_IDX_UPGRADE_URL}" + return error return None diff --git a/tests/test_integration.py b/tests/test_integration.py index 35a8ed8..0f99b0a 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -115,7 +115,7 @@ async def test_validate_schema_reports_the_pre_0_15_pending_index_shape( text(f'CREATE INDEX "{idx}" ON {outbox_table.name} (queue, next_attempt_at) WHERE acquired_token IS NULL'), ) client = OutboxClient(pg_engine, outbox_table) - with pytest.raises(RuntimeError, match="pending_idx"): + with pytest.raises(RuntimeError, match=r"pending_idx.*operations/alembic/#upgrading-to-015"): await client.validate_schema()