42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
"""Add data_source columns for provider tracking
|
|
|
|
Revision ID: a1b2c3d4e5f6
|
|
Revises: 6c3fce1dd49a
|
|
Create Date: 2026-01-01 14:30:00.000000
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = 'a1b2c3d4e5f6'
|
|
down_revision: Union[str, None] = '6c3fce1dd49a'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# Add data_source column to daily_health_metrics
|
|
op.add_column(
|
|
'daily_health_metrics',
|
|
sa.Column('data_source', sa.String(50), nullable=True, server_default='google_fit')
|
|
)
|
|
|
|
# Add data_source column to workout_sessions
|
|
op.add_column(
|
|
'workout_sessions',
|
|
sa.Column('data_source', sa.String(50), nullable=True, server_default='google_fit')
|
|
)
|
|
|
|
# Update existing rows to have default value
|
|
op.execute("UPDATE daily_health_metrics SET data_source = 'google_fit' WHERE data_source IS NULL")
|
|
op.execute("UPDATE workout_sessions SET data_source = 'google_fit' WHERE data_source IS NULL")
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_column('daily_health_metrics', 'data_source')
|
|
op.drop_column('workout_sessions', 'data_source')
|