quicksimpleapi-hd2mdt/migrations/versions/001_create_items_table.py
Automated Action cbb631170b Create a quick and simple FastAPI application with SQLite
This commit includes:
- Basic project structure with FastAPI
- SQLite database integration using SQLAlchemy
- CRUD API for items
- Alembic migrations setup
- Health check endpoint
- Proper error handling
- Updated README with setup instructions
2025-06-06 00:29:59 +00:00

37 lines
1.1 KiB
Python

"""create items table
Revision ID: 001
Revises:
Create Date: 2023-08-15 10:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.sql import func
# revision identifiers, used by Alembic.
revision = '001'
down_revision = None
branch_labels = None
depends_on = None
def upgrade() -> None:
op.create_table(
'items',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=False),
sa.Column('description', sa.String(), nullable=True),
sa.Column('is_active', sa.Boolean(), default=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=func.now()),
sa.Column('updated_at', sa.DateTime(timezone=True), onupdate=func.now()),
sa.PrimaryKeyConstraint('id'),
)
op.create_index(op.f('ix_items_id'), 'items', ['id'], unique=False)
op.create_index(op.f('ix_items_name'), 'items', ['name'], unique=False)
def downgrade() -> None:
op.drop_index(op.f('ix_items_name'), table_name='items')
op.drop_index(op.f('ix_items_id'), table_name='items')
op.drop_table('items')