"""v0.7.2 migration

Revision ID: 85f474ec5db2
Revises: 446a199ddd37
Create Date: 2025-01-06 16:26:06.873214

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision: str = '85f474ec5db2'
down_revision: Union[str, None] = '446a199ddd37'
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.create_table('users_sessions',
    sa.Column('id', sa.String(length=36), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False, comment='User ID that the session belongs'),
    sa.Column('refresh_token', sa.String(length=500), nullable=False, comment='Session refresh token'),
    sa.Column('ip_address', sa.String(length=45), nullable=False, comment='Client IP address'),
    sa.Column('device_type', sa.String(length=45), nullable=False, comment='Device type'),
    sa.Column('operating_system', sa.String(length=45), nullable=False, comment='Operating system'),
    sa.Column('operating_system_version', sa.String(length=45), nullable=False, comment='Operating system version'),
    sa.Column('browser', sa.String(length=45), nullable=False, comment='Browser'),
    sa.Column('browser_version', sa.String(length=45), nullable=False, comment='Browser version'),
    sa.Column('created_at', sa.DateTime(), nullable=False, comment='Session creation date (datetime)'),
    sa.Column('expires_at', sa.DateTime(), nullable=False, comment='Session expiration date (datetime)'),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_users_sessions_user_id'), 'users_sessions', ['user_id'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_users_sessions_user_id'), table_name='users_sessions')
    op.drop_table('users_sessions')
    # ### end Alembic commands ###
