"""add request/response payload columns to erp_api_call_logs

Records the erp-api exchange itself alongside the existing metadata: what
was SENT (request_params for the querystring, request_body for a JSON body)
and what came BACK (response_body). All three are nullable, so every row
written before this migration stays valid and rows written with
ERP_LOG_PAYLOADS off simply leave them NULL.

Revision ID: d3a7f1c05b28
Revises: b7f2c9d1a3e4
Create Date: 2026-09-07 00:00:00.000000

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


revision: str = 'd3a7f1c05b28'
down_revision: Union[str, Sequence[str], None] = 'b7f2c9d1a3e4'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.add_column('erp_api_call_logs', sa.Column('request_params', sa.JSON(), nullable=True))
    op.add_column('erp_api_call_logs', sa.Column('request_body', sa.JSON(), nullable=True))
    op.add_column('erp_api_call_logs', sa.Column('response_body', sa.JSON(), nullable=True))


def downgrade() -> None:
    op.drop_column('erp_api_call_logs', 'response_body')
    op.drop_column('erp_api_call_logs', 'request_body')
    op.drop_column('erp_api_call_logs', 'request_params')
