"""add max_count column to user_oauth_app

Revision ID: 0a861ba0828b
Revises: 780226f22449
Create Date: 2026-06-12 11:42:53.099895
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


revision: str = '0a861ba0828b'
down_revision: Union[str, None] = '780226f22449'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.add_column('user_oauth_app', sa.Column('max_count', sa.BigInteger(), nullable=True, comment='应用最大可以授权多少个用户'))
    op.execute('UPDATE user_oauth_app SET max_count = 100 WHERE max_count IS NULL')
    op.alter_column('user_oauth_app', 'max_count', nullable=False)


def downgrade() -> None:
    op.drop_column('user_oauth_app', 'max_count')