37 lines
1020 B
Python
37 lines
1020 B
Python
"""Initial migration
|
|
|
|
Revision ID: 001
|
|
Revises:
|
|
Create Date: 2023-10-22
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '001'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# Create item table
|
|
op.create_table(
|
|
'item',
|
|
sa.Column('id', sa.String(36), primary_key=True, index=True),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
|
sa.Column('name', sa.String(100), index=True, nullable=False),
|
|
sa.Column('description', sa.Text(), nullable=True),
|
|
sa.Column('is_active', sa.Boolean(), default=True),
|
|
)
|
|
op.create_index(op.f('ix_item_id'), 'item', ['id'], unique=False)
|
|
op.create_index(op.f('ix_item_name'), 'item', ['name'], unique=False)
|
|
|
|
|
|
def downgrade():
|
|
op.drop_index(op.f('ix_item_name'), table_name='item')
|
|
op.drop_index(op.f('ix_item_id'), table_name='item')
|
|
op.drop_table('item') |