| 24 | |
| 25 | # Define test models |
| 26 | class User(Base): |
| 27 | __tablename__ = 'users' |
| 28 | |
| 29 | id = Column(Integer, primary_key=True) |
| 30 | username = Column(String(50), unique=True, nullable=False) |
| 31 | email = Column(String(100), unique=True, nullable=False) |
| 32 | full_name = Column(String(100)) |
| 33 | age = Column(Integer) |
| 34 | balance = Column(DECIMAL(10, 2), default=Decimal('0.00')) |
| 35 | is_active = Column(Boolean, default=True) |
| 36 | created_at = Column(DateTime, default=func.now()) |
| 37 | birth_date = Column(Date) |
| 38 | bio = Column(Text) |
| 39 | metadata_json = Column(JSON) |
| 40 | |
| 41 | # Relationships |
| 42 | posts = relationship("Post", back_populates="author", cascade="all, delete-orphan") |
| 43 | |
| 44 | # Indexes |
| 45 | __table_args__ = ( |
| 46 | Index('idx_username_email', 'username', 'email'), |
| 47 | UniqueConstraint('username', 'email', name='unique_user_constraint'), |
| 48 | ) |
| 49 | |
| 50 | class Post(Base): |
| 51 | __tablename__ = 'posts' |
no outgoing calls