Add migration for Book
This commit is contained in:
parent
e0e4545946
commit
61a391a7ea
35
alembic/versions/20250326_164448_5653c6f5_create_book.py
Normal file
35
alembic/versions/20250326_164448_5653c6f5_create_book.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
"""create books table
|
||||||
|
|
||||||
|
Revision ID: 1234567890ab
|
||||||
|
Revises:
|
||||||
|
Create Date: 2023-05-24 10:00:00.000000
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects.postgresql import UUID
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '1234567890ab'
|
||||||
|
down_revision = None
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.create_table(
|
||||||
|
'books',
|
||||||
|
sa.Column('id', UUID(as_uuid=True), primary_key=True),
|
||||||
|
sa.Column('title', sa.String, nullable=False),
|
||||||
|
sa.Column('author', sa.String, nullable=False),
|
||||||
|
sa.Column('description', sa.String),
|
||||||
|
sa.Column('pages', sa.Integer),
|
||||||
|
sa.Column('published_year', sa.Integer),
|
||||||
|
sa.Column('created_at', sa.DateTime, server_default=sa.func.now()),
|
||||||
|
sa.Column('updated_at', sa.DateTime, server_default=sa.func.now(), onupdate=sa.func.now())
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_table('books')
|
Loading…
x
Reference in New Issue
Block a user