I have an issue with invalid enum input when trying to update my database model. The error is below. I am not sure what I am doing wrong
sqlalchemy.exc.DataError: (psycopg2.errors.InvalidTextRepresentation) invalid input value for enum recipientstatus
Here is the enum I used and the model
class RecipientStatus(enum.Enum):
WAITING_TO_SEND = "WAITING_TO_SEND"
PENDING_TO_SEND = "PENDING_TO_SEND"
class Recipient(db.Model):
status = db.Column(db.Enum(RecipientStatus))
The code below is a sample of what I want the enum to do. For some reason, it is not recognizing the enum of the code
for recipients in recipients:
recipient.status = RecipientStatus.FAILED_TO_SEND.value
recipient.status_changed_at = datetime.now(timezone.utc)
db.session.commit()
This is the alembic command if it helps
def upgrade():
recipient_status_enum = ENUM(
"WAITING_TO_SEND",
"PENDING_TO_SEND",
name="recipientstatus",
)
recipient_status_enum.create(op.get_bind(), checkfirst=True)
op.add_column(
"recipient", sa.Column("status", recipient_status_enum, nullable=True)
)
I tried changing the enum. I tried without the .value of the ENUM but it still gives me an error