25 lines
1.0 KiB
Python
25 lines
1.0 KiB
Python
from sqlalchemy import Column, String, Integer, DateTime, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
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)
|
|
author = Column(String, nullable=False)
|
|
description = Column(String, nullable=True)
|
|
publisher = Column(String, nullable=True)
|
|
publication_year = Column(Integer, nullable=True)
|
|
isbn = Column(String, unique=True, index=True, nullable=False)
|
|
pages = 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())
|
|
|
|
# Relationships if needed
|
|
# category_id = Column(UUID(as_uuid=True), ForeignKey('categories.id'), nullable=True)
|
|
# category = relationship("Category", back_populates="books") |