"""date_attr_update_on_json_null_options

Revision ID: 0274
Revises: 0273
Create Date: 2025-07-11 09:36:08.483552

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql


# revision identifiers, used by Alembic.
revision = '0274'
down_revision = '0273'
branch_labels = None
depends_on = None


def upgrade():
    op.execute("""
        UPDATE attributes
        SET options =
            jsonb_set(
                jsonb_set(
                    '{}'::jsonb,
                    '{precision}',
                    '"days"'::jsonb,
                    true
                ),
                '{daterange}',
                'true'::jsonb,
                true
            )
        WHERE type_name = 'date'
          AND options = 'null'::jsonb;
    """)


def downgrade():
    pass
