update column constraint when adding enum item
bbbart opened this issue · comments
Describe the bug
When creating a new version script (I use Flask-Migrate), alembic reports it finds no changes in my schema when I add an item to an enum used as a column constraint.
Expected behavior
I was hoping to get a migration script with an appropriate alter_column
method applied
To Reproduce
class ProblemType(IntEnum):
SPLIT = auto()
ADD = auto()
SUBTRACT = auto()
ADDSUB = auto()
and later
class ProblemSheet(DB.Model):
problem_type: DB.Mapped[ProblemType] = DB.mapped_column(
DB.Enum(
ProblemType,
create_constraint=True,
values_callable=lambda x: [str(i.value) for i in x],
)
)
now:
- initialise the database
- add an item to the ProblemType IntEnum
- migrate the database
Error
No change will be detected, leaving my application in a state in which it cannot be used to add problem sheets of the new problem type.
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.env] No changes in schema detected.
Versions.
- OS: x86_64 GNU/Linux
- Python: 3.9.2
- Alembic: 1.13.1
- SQLAlchemy: 2.0.25
- Database: SQLite
- DBAPI: aiosqlite
Additional context
This is a Flask app with the Flask-Migrate wrapper around alembic.
Have a nice day and a great 2024!
Hi
This is a duplicate of #363 and partially of #278
There is a 3rd party extension that improves thing for postgresql, I don't know if it works also for sqlite https://github.com/Pogchamp-company/alembic-postgresql-enum
I see. Thanks for following this up!