Automated Action f14ce141af Fix database migration error related to app module imports
- Fixed circular import issue between base.py and base_class.py
- Updated base_class.py to define Base directly and import models
- Refactored base.py to import Base from base_class.py
- Updated all models to import Base from base_class.py
- Enhanced error handling in migrations/env.py to catch ImportError
2025-06-12 17:46:42 +00:00

23 lines
832 B
Python

from datetime import datetime
from sqlalchemy import Column, DateTime, Float, Integer, String, Text
from sqlalchemy.orm import relationship
from app.db.base_class import Base
class Product(Base):
__tablename__ = "products"
id = Column(Integer, primary_key=True, index=True)
name = Column(String, index=True, nullable=False)
description = Column(Text, nullable=True)
price = Column(Float, nullable=False)
stock = Column(Integer, default=0, nullable=False)
image_url = Column(String, nullable=True)
created_at = Column(DateTime, default=datetime.utcnow)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
# Relationships
order_items = relationship("OrderItem", back_populates="product")
cart_items = relationship("CartItem", back_populates="product")