"""adding user.last_login_at

Revision ID: 71bc1df82e6a
Revises: 0f3d2b1a7c21
Create Date: 2025-11-16 19:40:40.794367

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
import sqlmodel
import sqlmodel.sql.sqltypes
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = '71bc1df82e6a'
down_revision: Union[str, None] = '0f3d2b1a7c21'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('authz_mv_meta')
    with op.batch_alter_table('users', schema=None) as batch_op:
        batch_op.add_column(sa.Column('last_login', postgresql.JSONB(astext_type=sa.Text()), nullable=True))

    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('users', schema=None) as batch_op:
        batch_op.drop_column('last_login')

    op.create_table('authz_mv_meta',
    sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('last_source_ts', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True),
    sa.Column('refreshed_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name=op.f('authz_mv_meta_pkey'))
    )
    # ### end Alembic commands ###
