
- Setup FastAPI project structure with main.py and requirements.txt - Implement SQLAlchemy ORM with SQLite database - Create Item model with CRUD operations - Implement health endpoint for monitoring - Setup Alembic for database migrations - Add comprehensive documentation in README.md - Configure Ruff for code linting
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
"""initial migration
|
|
|
|
Revision ID: 000001
|
|
Revises:
|
|
Create Date: 2023-07-01
|
|
|
|
"""
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '000001'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# Create items table
|
|
op.create_table(
|
|
'items',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('title', sa.String(), nullable=True),
|
|
sa.Column('description', sa.String(), nullable=True),
|
|
sa.Column('is_active', sa.Boolean(), nullable=True, default=True),
|
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)')),
|
|
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_items_id'), 'items', ['id'], unique=False)
|
|
op.create_index(op.f('ix_items_title'), 'items', ['title'], unique=False)
|
|
op.create_index(op.f('ix_items_description'), 'items', ['description'], unique=False)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index(op.f('ix_items_description'), table_name='items')
|
|
op.drop_index(op.f('ix_items_title'), table_name='items')
|
|
op.drop_index(op.f('ix_items_id'), table_name='items')
|
|
op.drop_table('items')
|