From 0b5aa1d1a3b2ffd5f87ae1ad713cc2ec8b03dba9 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Fri, 28 Mar 2025 13:18:31 +0000 Subject: [PATCH] Add Book model --- models/book.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 models/book.py diff --git a/models/book.py b/models/book.py new file mode 100644 index 0000000..f6d1e2b --- /dev/null +++ b/models/book.py @@ -0,0 +1,21 @@ +from sqlalchemy import Column, String, DateTime, Text, Integer +from sqlalchemy.dialects.postgresql import UUID +from sqlalchemy.sql import func +from core.database import Base +import uuid + +class Book(Base): + __tablename__ = "books" + + id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) + title = Column(String, nullable=False, index=True) + author = Column(String, nullable=False) + description = Column(Text, nullable=True) + isbn = Column(String, unique=True, nullable=False) + publication_year = Column(Integer, nullable=True) + publisher = Column(String, nullable=True) + page_count = Column(Integer, nullable=True) + language = Column(String, nullable=True) + + created_at = Column(DateTime, default=func.now()) + updated_at = Column(DateTime, default=func.now(), onupdate=func.now()) \ No newline at end of file