'sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DuplicateObject) type "orderstatus" already exists. Is the problem in my model or in my database?
I am developing a flask microservice application. I get this issue when I use the command flask db migrate the database. I want to use OrderStatus class inside Enum function. I couldn't find the reason for this. Is the problem in my model or in my database configuration?
class OrderStatus(enum.Enum):
new = "NEW"
preparing = "PREPARING"
on_the_way = "ON THE WAY"
delivery = "DELIVERED"
cancel = "CANCEL"
class Order(db.Model):
""" Orders model for storing menu related data """
__tablename__ = 'order'
id = db.Column(db.Integer, primary_key=True)
order_id = db.Column(db.String(256),index=True)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), index=True)
menu_id = db.Column(db.Integer, db.ForeignKey('menu.id'), index=True)
restaurant_id = db.Column(db.Integer, db.ForeignKey('restaurant.id'), index=True)
status = db.Column(db.Enum(OrderStatus), default="New")
created_on = db.Column(db.DateTime, default=datetime.utcnow)```
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
