Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion faststream_outbox/schema_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
Loading