
- Set up FastAPI application structure - Implemented SQLite database integration with SQLAlchemy - Added Alembic migrations for database versioning - Created bet model and API endpoints for CRUD operations - Added comprehensive README with setup and usage instructions - Added health check endpoint and CORS support
48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
"""create bet table
|
|
|
|
Revision ID: 1b98a4720ea1
|
|
Revises:
|
|
Create Date: 2023-10-15 12:00:00.000000
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '1b98a4720ea1'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# Create bet table
|
|
op.create_table('bet',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('user_id', sa.String(), nullable=False, index=True),
|
|
sa.Column('event_id', sa.String(), nullable=False, index=True),
|
|
sa.Column('amount', sa.Float(), nullable=False),
|
|
sa.Column('odds', sa.Float(), nullable=False),
|
|
sa.Column('prediction', sa.String(), nullable=False),
|
|
sa.Column('is_verified', sa.Boolean(), nullable=False, default=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=False, default=sa.func.current_timestamp()),
|
|
sa.Column('verified_at', sa.DateTime(), nullable=True),
|
|
sa.Column('result', sa.String(), nullable=True),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
|
|
# Create indexes
|
|
op.create_index(op.f('ix_bet_id'), 'bet', ['id'], unique=False)
|
|
op.create_index(op.f('ix_bet_user_id'), 'bet', ['user_id'], unique=False)
|
|
op.create_index(op.f('ix_bet_event_id'), 'bet', ['event_id'], unique=False)
|
|
|
|
|
|
def downgrade() -> None:
|
|
# Drop indexes
|
|
op.drop_index(op.f('ix_bet_event_id'), table_name='bet')
|
|
op.drop_index(op.f('ix_bet_user_id'), table_name='bet')
|
|
op.drop_index(op.f('ix_bet_id'), table_name='bet')
|
|
|
|
# Drop table
|
|
op.drop_table('bet') |