Add Book model
This commit is contained in:
parent
15fc6ed474
commit
ff6e5729d2
17
models/book.py
Normal file
17
models/book.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
from sqlalchemy import Column, String, Integer, ForeignKey, DateTime
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
from sqlalchemy.sql import func
|
||||||
|
from core.database import Base
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
class Book(Base):
|
||||||
|
__tablename__ = "books"
|
||||||
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
|
title = Column(String, nullable=False)
|
||||||
|
author = Column(String, nullable=False, index=True)
|
||||||
|
description = Column(String, nullable=True)
|
||||||
|
page_count = Column(Integer, nullable=False)
|
||||||
|
published_date = Column(DateTime, nullable=False)
|
||||||
|
isbn = Column(String, unique=True, nullable=False, index=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