
- Setup FastAPI project structure - Add database models for calculations - Create API endpoints for basic math operations - Add health endpoint - Configure SQLite and Alembic for database management - Update README with usage instructions generated with BackendIM... (backend.im)
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""initial setup
|
|
|
|
Revision ID: 001
|
|
Revises:
|
|
Create Date: 2025-05-13
|
|
|
|
"""
|
|
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() -> None:
|
|
# Create calculation table
|
|
op.create_table(
|
|
'calculation',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('operation', sa.String(), nullable=False),
|
|
sa.Column('first_number', sa.Float(), nullable=False),
|
|
sa.Column('second_number', sa.Float(), nullable=True),
|
|
sa.Column('result', sa.Float(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_calculation_id'), 'calculation', ['id'], unique=False)
|
|
op.create_index(op.f('ix_calculation_operation'), 'calculation', ['operation'], unique=False)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index(op.f('ix_calculation_operation'), table_name='calculation')
|
|
op.drop_index(op.f('ix_calculation_id'), table_name='calculation')
|
|
op.drop_table('calculation') |