21 lines
834 B
Python
21 lines
834 B
Python
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()) |