
- 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
23 lines
824 B
Python
23 lines
824 B
Python
from datetime import datetime
|
|
from sqlalchemy import Boolean, Column, DateTime, Integer, String
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.base_class import Base
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
email = Column(String, unique=True, index=True, nullable=False)
|
|
hashed_password = Column(String, nullable=False)
|
|
full_name = Column(String, index=True)
|
|
is_active = Column(Boolean, default=True)
|
|
is_superuser = Column(Boolean, default=False)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
|
|
# Relationships
|
|
orders = relationship("Order", back_populates="user")
|
|
cart_items = relationship("CartItem", back_populates="user")
|