Open lotruheawea opened 5 days ago
I have tried to reproduce your issue in a test case. It passes. Either you have a problem with your test or I am missing something that you have in it.
Mmh, we use sqlalchemy v1.4.52
and alembic v.1.13.2
. Maybe it is because we use the old version of sqlalchemy?
Our tests run with different sqlalchemy versions. sync_enum_values does not use insert
under the hood. I'm inclined to think that something is wrong in your test
I tried to do some research, but also found this dead end: https://stackoverflow.com/questions/59082387/attributeerror-uuid-object-has-no-attribute-replace. I am not sure, if this is helpful.
In the end, my test is the native pytest-alembic.tests.test_up_down_consistency
(version v0.11.0
)... I can also post the initial migration, if helpful:
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"unit",
sa.Column("id", sa.BigInteger(), autoincrement=True, nullable=False),
sa.Column("resource_id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column(
"identifier_type",
sa.Enum(
"A",
"B",
name="identifier_type_enum",
),
nullable=False,
),
sa.Column("identifier", sa.BigInteger(), nullable=False),
sa.Column(
"created",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=False,
),
sa.PrimaryKeyConstraint("id", name=op.f("pk_unit")),
sa.UniqueConstraint(
"identifier", "identifier_type", name=op.f("uq_unit_identifier")
),
sa.UniqueConstraint("resource_id", name=op.f("uq_unit_resource_id")),
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("unit")
# ### end Alembic commands ###
# Manually added commands to drop enums
sa.Enum(name="identifier_type_enum").drop(op.get_bind(), checkfirst=False)
Hi I try to reduce my problem to the most relevant bits. My ORM looks like this:
I have updated the IdentifierType Enum like so:
and got these migrations:
And I get this error in my
pytest-alembic.tests.test_up_down_consistency
:How can this be solved? Thank you very much for your support!