79377904

Date: 2025-01-22 13:40:25
Score: 0.5
Natty:
Report link

The solution lies in removing the explicit definition of the public schema in your classes.

So if you have this in your bar class

bar_id: Mapped[Integer] = mapped_column(
        ForeignKey("public.bar.id"), index=True, type_=Integer
    )

And in your foo class

__table_args__ = (
    {"schema": "public"},
)

Remove both public statements. Postgres does sometimes not explicitly name it that way and alembic then thinks it is a different FK and tries to recreate them.

Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: tnfru