35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
"""create table for weather_forecasts
|
|
Revision ID: 1a2b3c4d5e6f
|
|
Revises: 0001
|
|
Create Date: 2023-05-24 12:00:00
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.sql import func
|
|
import uuid
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '1a2b3c4d5e6f'
|
|
down_revision = '0001'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
def upgrade():
|
|
op.create_table(
|
|
'weather_forecasts',
|
|
sa.Column('id', sa.String(36), primary_key=True, default=lambda: str(uuid.uuid4())),
|
|
sa.Column('location', sa.String(), nullable=False),
|
|
sa.Column('date', sa.DateTime(), nullable=False),
|
|
sa.Column('temperature', sa.Float(), nullable=False),
|
|
sa.Column('humidity', sa.Float(), nullable=False),
|
|
sa.Column('wind_speed', sa.Float(), nullable=False),
|
|
sa.Column('precipitation_probability', sa.Float(), nullable=False),
|
|
sa.Column('description', sa.String(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), server_default=func.now()),
|
|
sa.Column('updated_at', sa.DateTime(), server_default=func.now(), onupdate=func.now()),
|
|
sa.Index('ix_weather_forecasts_location', 'location'),
|
|
sa.Index('ix_weather_forecasts_date', 'date')
|
|
)
|
|
|
|
def downgrade():
|
|
op.drop_table('weather_forecasts') |