38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
"""initial migration
|
|
|
|
Revision ID: 01_initial_migration
|
|
Revises:
|
|
Create Date: 2023-10-15
|
|
|
|
"""
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '01_initial_migration'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# Create item table
|
|
op.create_table(
|
|
'item',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
|
sa.Column('name', sa.String(length=255), nullable=False),
|
|
sa.Column('description', sa.Text(), nullable=True),
|
|
sa.Column('is_active', sa.Boolean(), nullable=True),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
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() -> None:
|
|
# Drop item table
|
|
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') |