45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
"""Rename indicator_key bra → rnb (GfE ruminal nitrogen balance).
|
|
|
|
Revision ID: lab_rnb_rename
|
|
Revises: lab_drop_legacy_artifacts
|
|
Create Date: 2026-06-09
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision = "lab_rnb_rename"
|
|
down_revision = "lab_drop_legacy_artifacts"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade(**kw) -> None:
|
|
if kw.get("tag") == "reports":
|
|
return
|
|
bind = op.get_bind()
|
|
bind.execute(
|
|
sa.text("UPDATE lab_profile_norm SET indicator_key = 'rnb' WHERE indicator_key = 'bra'")
|
|
)
|
|
bind.execute(
|
|
sa.text(
|
|
"UPDATE lab_ration_calc_indicator SET indicator_key = 'rnb' WHERE indicator_key = 'bra'"
|
|
)
|
|
)
|
|
|
|
|
|
def downgrade(**kw) -> None:
|
|
if kw.get("tag") == "reports":
|
|
return
|
|
bind = op.get_bind()
|
|
bind.execute(
|
|
sa.text("UPDATE lab_profile_norm SET indicator_key = 'bra' WHERE indicator_key = 'rnb'")
|
|
)
|
|
bind.execute(
|
|
sa.text(
|
|
"UPDATE lab_ration_calc_indicator SET indicator_key = 'bra' WHERE indicator_key = 'rnb'"
|
|
)
|
|
)
|