"""Give role-change keyset ordering microsecond precision. Revision ID: 447 Revises: 446 Create Date: 2026-08-02 The role-change list fixes a traversal at an application-clock timestamp. MySQL DATETIME(0) rounded every event in the same wall-clock second onto the same value, so a row committed after page one could still compare below that snapshot. DATETIME(6) makes the persisted ordering key match the cursor. """ from __future__ import annotations import sqlalchemy as sa from sqlalchemy.dialects import mysql from alembic import op revision = "447" down_revision = "446" branch_labels = None depends_on = None def upgrade() -> None: op.alter_column( "hr_lifecycle_events", "created_at", existing_type=sa.DateTime(), type_=mysql.DATETIME(fsp=6), existing_nullable=False, existing_server_default=sa.text("CURRENT_TIMESTAMP"), server_default=sa.text("CURRENT_TIMESTAMP(6)"), ) def downgrade() -> None: op.alter_column( "hr_lifecycle_events", "created_at", existing_type=mysql.DATETIME(fsp=6), type_=sa.DateTime(), existing_nullable=False, existing_server_default=sa.text("CURRENT_TIMESTAMP(6)"), server_default=sa.text("CURRENT_TIMESTAMP"), )