Add Book model
This commit is contained in:
parent
ecdaa8a627
commit
c4af320dc6
21
models/book.py
Normal file
21
models/book.py
Normal file
@ -0,0 +1,21 @@
|
||||
from sqlalchemy import Column, String, Integer, Boolean, DateTime, Text
|
||||
from sqlalchemy.sql import func
|
||||
from core.database import Base
|
||||
import uuid
|
||||
|
||||
class Book(Base):
|
||||
__tablename__ = "books"
|
||||
|
||||
id = Column(String, primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||
title = Column(String, nullable=False, index=True)
|
||||
author = Column(String, nullable=False)
|
||||
description = Column(Text)
|
||||
isbn = Column(String, unique=True)
|
||||
publication_year = Column(Integer)
|
||||
publisher = Column(String)
|
||||
cover_image = Column(String)
|
||||
price = Column(Integer)
|
||||
is_available = Column(Boolean, default=True)
|
||||
|
||||
created_at = Column(DateTime, default=func.now())
|
||||
updated_at = Column(DateTime, default=func.now(), onupdate=func.now())
|
Loading…
x
Reference in New Issue
Block a user