sqlalchemy / sqlalchemy/alembic
batch_alter_table forgets unchanged Enum CHECK constraint
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 375
- PR merge metrics
- No merged PRs in 30d
Description
Migrated issue, originally created by Jeremy Field (@jdf-id-au)
Using batch_alter_table to change an Enum in sqlite causes CHECK constraint for another Enum to be lost.
Working example at repo.
The documentation makes it look like this shouldn't happen.
When trying to reinstate lost Enum constraints on other columns, only the last batch_op.alter_column call seems to result in a CHECK constraint being created.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the batch_alter_table documentation section on changing Boolean, Enum, and other implicit CHECK datatypes, then reproduce the behavior using the linked working example. Trace how multiple batch_op.alter_column calls handle unchanged Enum constraints; done means existing CHECK constraints are preserved and each intended Enum constraint is recreated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlalchemy, sqlite
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100