34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
"""Initial creation of books table
|
|
Revision ID: 1a2b3c4d5e6f
|
|
Revises: 0001
|
|
Create Date: 2023-07-21 10:00:00.000000
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '1a2b3c4d5e6f'
|
|
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('description', sa.Text(), nullable=True),
|
|
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') |