32 lines
1009 B
Python
32 lines
1009 B
Python
"""Initial creation of Book model
|
|
Revision ID: a1b2c3d4e5f6
|
|
Revises: 0001
|
|
Create Date: 2023-11-17 10:00:00.000000
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '3c1332db'
|
|
down_revision = '0001'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
op.create_table(
|
|
'books',
|
|
sa.Column('id', sa.String(36), primary_key=True),
|
|
sa.Column('title', sa.String(), nullable=False),
|
|
sa.Column('author', sa.String(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), server_default=sa.func.now()),
|
|
sa.Column('updated_at', sa.DateTime(), server_default=sa.func.now()),
|
|
)
|
|
op.create_index(op.f('ix_books_title'), 'books', ['title'], unique=False)
|
|
op.create_index(op.f('ix_books_author'), 'books', ['author'], unique=False)
|
|
|
|
|
|
def downgrade():
|
|
op.drop_index(op.f('ix_books_author'), table_name='books')
|
|
op.drop_index(op.f('ix_books_title'), table_name='books')
|
|
op.drop_table('books') |