Add Book model

This commit is contained in:
Backend IM Bot 2025-03-25 23:20:41 +00:00
parent 23474fb3d3
commit bba7849e37

View File

@ -11,12 +11,13 @@ class Book(Base):
title = Column(String, nullable=False, index=True)
description = Column(String)
isbn = Column(String, unique=True)
publication_year = Column(Integer)
author_id = Column(String, ForeignKey("authors.id"), nullable=False)
publication_year = Column(Integer)
pages = Column(Integer)
genre = Column(String)
publisher = Column(String)
# Relationships
author = relationship("Author", back_populates="books")
# Timestamps
created_at = Column(DateTime, default=func.now())
updated_at = Column(DateTime, default=func.now(), onupdate=func.now())
author = relationship("Author", back_populates="books")