42 lines
1.8 KiB
Python
42 lines
1.8 KiB
Python
"""Daily recovery, individual effort bands and private session context."""
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision = "7c6e32b491ad"
|
|
down_revision = "f31a0c9286bd"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
with op.batch_alter_table("garmin_connection") as batch:
|
|
batch.add_column(sa.Column("health_enabled", sa.Boolean(), nullable=False,
|
|
server_default=sa.false()))
|
|
batch.add_column(sa.Column("health_message", sa.String(200), nullable=False,
|
|
server_default="Daily recovery sync is off."))
|
|
with op.batch_alter_table("user") as batch:
|
|
batch.add_column(sa.Column("hr_bands", sa.JSON()))
|
|
with op.batch_alter_table("activity") as batch:
|
|
batch.add_column(sa.Column("session_context", sa.JSON(), nullable=False,
|
|
server_default="{}"))
|
|
op.create_table("daily_health",
|
|
sa.Column("id", sa.Integer(), primary_key=True),
|
|
sa.Column("owner_id", sa.Integer(), sa.ForeignKey("user.id"), nullable=False),
|
|
sa.Column("day", sa.Date(), nullable=False),
|
|
sa.Column("values", sa.JSON(), nullable=False),
|
|
sa.Column("fetched_at", sa.DateTime(timezone=True), nullable=False),
|
|
sa.UniqueConstraint("owner_id", "day"))
|
|
op.create_index("ix_daily_health_owner_id", "daily_health", ["owner_id"])
|
|
|
|
|
|
def downgrade():
|
|
op.drop_table("daily_health")
|
|
with op.batch_alter_table("activity") as batch:
|
|
batch.drop_column("session_context")
|
|
with op.batch_alter_table("user") as batch:
|
|
batch.drop_column("hr_bands")
|
|
with op.batch_alter_table("garmin_connection") as batch:
|
|
batch.drop_column("health_message")
|
|
batch.drop_column("health_enabled")
|