21 lines
667 B
Python
21 lines
667 B
Python
from sqlalchemy import Column, String, Text
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.models.base import BaseModel
|
|
|
|
|
|
class Artist(BaseModel):
|
|
"""Artist model representing a musician or band."""
|
|
|
|
__tablename__ = "artists"
|
|
|
|
name = Column(String, nullable=False, index=True)
|
|
bio = Column(Text, nullable=True)
|
|
image_path = Column(String, nullable=True) # Path to artist image
|
|
|
|
# Relationships
|
|
albums = relationship("Album", back_populates="artist", cascade="all, delete-orphan")
|
|
songs = relationship("Song", back_populates="artist", cascade="all, delete-orphan")
|
|
|
|
def __repr__(self):
|
|
return f"<Artist {self.name}>" |