35 lines
917 B
Python
35 lines
917 B
Python
"""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') |