mirror of
https://github.com/flibusta-apps/book_library_server.git
synced 2025-12-06 15:15:36 +01:00
Add pages to Book
This commit is contained in:
29
fastapi_book_server/app/alembic/versions/b44117a41999_.py
Normal file
29
fastapi_book_server/app/alembic/versions/b44117a41999_.py
Normal file
@@ -0,0 +1,29 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: b44117a41999
|
||||
Revises: 08193b547a80
|
||||
Create Date: 2021-11-18 18:25:06.921287
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.sql.schema import UniqueConstraint
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "b44117a41999"
|
||||
down_revision = "08193b547a80"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column("books", sa.Column("pages", sa.Integer(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column("books", "pages")
|
||||
# ### end Alembic commands ###
|
||||
@@ -1,4 +1,5 @@
|
||||
from datetime import date
|
||||
from typing import Optional
|
||||
|
||||
import ormar
|
||||
from sqlalchemy import text
|
||||
@@ -150,6 +151,7 @@ class Book(ormar.Model):
|
||||
is_deleted: bool = ormar.Boolean(
|
||||
default=False, server_default=text("false"), nullable=False
|
||||
)
|
||||
pages: Optional[int] = ormar.Integer(minimum=0, nullable=True) # type: ignore
|
||||
|
||||
authors = ormar.ManyToMany(Author, through=BookAuthors)
|
||||
translators = ormar.ManyToMany(
|
||||
|
||||
Reference in New Issue
Block a user