sqlalchemy / sqlalchemy/alembic
enum already exists
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 375
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
Whenever I am adding Enum field in a new model it's giving me this error "sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DuplicateObject) type "tickettype" already exists" for resolving this I have to delete DB and create a new one.
Optional link from https://docs.sqlalchemy.org which documents the behavior that is expected
https://docs.sqlalchemy.org/en/14/errors.html#error-f405
SQLAlchemy Version in Use
1.4.46
DBAPI (i.e. the database driver)
2.9.5
Database Vendor and Major Version
2.9.5
Python Version
3.8
Operating system
Linux
To Reproduce
alembic revision --autogenerate -m "New Migration"
alemic upgrade head
Error
# Copy the complete stack trace and error message here, including SQL log output if applicable.
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DuplicateObject) type "tickettype" already exists
[SQL: CREATE TYPE tickettype AS ENUM ('PAID', 'FREE', 'GROUP', 'DONATION', 'REQUEST', 'GUESTLIST')]
Additional context
No response
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 by reproducing the issue with the Alembic revision and upgrade commands, then inspect the generated migration and the PostgreSQL CREATE TYPE statement shown in the error. Compare the migration with the existing tickettype enum and determine what migration behavior should prevent the duplicate type error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python, sqlalchemy
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100