
- Implemented FastAPI application structure - Added OpenWeatherMap API integration - Created SQLite database with SQLAlchemy - Setup Alembic for database migrations - Added health check endpoint - Created comprehensive README generated with BackendIM... (backend.im)
58 lines
2.1 KiB
Python
58 lines
2.1 KiB
Python
"""initial migration
|
|
|
|
Revision ID: 55e2b32824ab
|
|
Revises:
|
|
Create Date: 2023-10-10 12:00:00.000000
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '55e2b32824ab'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# Create cities table
|
|
op.create_table('cities',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(), nullable=True),
|
|
sa.Column('country', sa.String(), nullable=True),
|
|
sa.Column('latitude', sa.Float(), nullable=True),
|
|
sa.Column('longitude', sa.Float(), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_cities_id'), 'cities', ['id'], unique=False)
|
|
op.create_index(op.f('ix_cities_name'), 'cities', ['name'], unique=False)
|
|
|
|
# Create weather_data table
|
|
op.create_table('weather_data',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('city_id', sa.Integer(), nullable=True),
|
|
sa.Column('temperature', sa.Float(), nullable=True),
|
|
sa.Column('feels_like', sa.Float(), nullable=True),
|
|
sa.Column('humidity', sa.Integer(), nullable=True),
|
|
sa.Column('pressure', sa.Integer(), nullable=True),
|
|
sa.Column('wind_speed', sa.Float(), nullable=True),
|
|
sa.Column('wind_direction', sa.Integer(), nullable=True),
|
|
sa.Column('description', sa.String(), nullable=True),
|
|
sa.Column('weather_main', sa.String(), nullable=True),
|
|
sa.Column('weather_icon', sa.String(), nullable=True),
|
|
sa.Column('timestamp', sa.DateTime(), nullable=True),
|
|
sa.ForeignKeyConstraint(['city_id'], ['cities.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_weather_data_id'), 'weather_data', ['id'], unique=False)
|
|
|
|
|
|
def downgrade():
|
|
op.drop_index(op.f('ix_weather_data_id'), table_name='weather_data')
|
|
op.drop_table('weather_data')
|
|
op.drop_index(op.f('ix_cities_name'), table_name='cities')
|
|
op.drop_index(op.f('ix_cities_id'), table_name='cities')
|
|
op.drop_table('cities') |