54 lines
2.2 KiB
Python
54 lines
2.2 KiB
Python
"""Add state tables
|
|
|
|
Revision ID: 85c60ed462bf
|
|
Revises: b5a6d7ef97a5
|
|
Create Date: 2026-01-01 17:01:04.348349
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = '85c60ed462bf'
|
|
down_revision: Union[str, None] = 'b5a6d7ef97a5'
|
|
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('garmin_activity_state',
|
|
sa.Column('garmin_activity_id', sa.String(), nullable=False),
|
|
sa.Column('activity_name', sa.String(), nullable=True),
|
|
sa.Column('activity_type', sa.String(), nullable=True),
|
|
sa.Column('start_time', sa.DateTime(), nullable=True),
|
|
sa.Column('sync_status', sa.String(), nullable=True),
|
|
sa.Column('last_seen', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
|
|
sa.PrimaryKeyConstraint('garmin_activity_id')
|
|
)
|
|
op.create_index(op.f('ix_garmin_activity_state_garmin_activity_id'), 'garmin_activity_state', ['garmin_activity_id'], unique=False)
|
|
op.create_table('health_sync_state',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('date', sa.Date(), nullable=False),
|
|
sa.Column('metric_type', sa.String(), nullable=False),
|
|
sa.Column('source', sa.String(), nullable=False),
|
|
sa.Column('sync_status', sa.String(), nullable=True),
|
|
sa.Column('last_seen', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('date', 'metric_type', 'source', name='uq_health_state')
|
|
)
|
|
op.create_index(op.f('ix_health_sync_state_id'), 'health_sync_state', ['id'], unique=False)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f('ix_health_sync_state_id'), table_name='health_sync_state')
|
|
op.drop_table('health_sync_state')
|
|
op.drop_index(op.f('ix_garmin_activity_state_garmin_activity_id'), table_name='garmin_activity_state')
|
|
op.drop_table('garmin_activity_state')
|
|
# ### end Alembic commands ###
|