added segments
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,62 @@
|
||||
"""Add segments tables
|
||||
|
||||
Revision ID: a9c00e495f5e
|
||||
Revises: 73e349ef1d88
|
||||
Create Date: 2026-01-09 18:23:42.393552
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'a9c00e495f5e'
|
||||
down_revision: Union[str, None] = '73e349ef1d88'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('segments',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(), nullable=False),
|
||||
sa.Column('description', sa.String(), nullable=True),
|
||||
sa.Column('distance', sa.Float(), nullable=False),
|
||||
sa.Column('avg_grade', sa.Float(), nullable=True),
|
||||
sa.Column('elevation_gain', sa.Float(), nullable=True),
|
||||
sa.Column('points', sa.JSON(), nullable=False),
|
||||
sa.Column('bounds', sa.JSON(), nullable=False),
|
||||
sa.Column('activity_type', sa.String(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_segments_id'), 'segments', ['id'], unique=False)
|
||||
op.create_table('segment_efforts',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('segment_id', sa.Integer(), nullable=False),
|
||||
sa.Column('activity_id', sa.Integer(), nullable=False),
|
||||
sa.Column('elapsed_time', sa.Integer(), nullable=False),
|
||||
sa.Column('start_time', sa.DateTime(), nullable=False),
|
||||
sa.Column('end_time', sa.DateTime(), nullable=False),
|
||||
sa.Column('avg_power', sa.Integer(), nullable=True),
|
||||
sa.Column('avg_hr', sa.Integer(), nullable=True),
|
||||
sa.Column('kom_rank', sa.Integer(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
|
||||
sa.ForeignKeyConstraint(['activity_id'], ['activities.id'], ),
|
||||
sa.ForeignKeyConstraint(['segment_id'], ['segments.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_segment_efforts_id'), 'segment_efforts', ['id'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_segment_efforts_id'), table_name='segment_efforts')
|
||||
op.drop_table('segment_efforts')
|
||||
op.drop_index(op.f('ix_segments_id'), table_name='segments')
|
||||
op.drop_table('segments')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user