"""add necessary chat fields to the user

Revision ID: 503fd4d18a54
Revises: 5876cd139e31
Create Date: 2023-08-27 07:19:35.276103+00:00

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '503fd4d18a54'
down_revision = '5876cd139e31'
branch_labels = None
depends_on = None


def upgrade():
    op.add_column('users', sa.Column('chat_authorized', sa.Boolean()))
    op.execute("UPDATE users SET chat_authorized = FALSE")
    op.alter_column('users', 'chat_authorized', nullable=False)

    op.add_column('users', sa.Column('chat_lastseen', sa.DateTime(timezone=True)))
    op.execute("UPDATE users SET chat_lastseen = '1970-01-01 00:00:00'")
    op.alter_column('users', 'chat_lastseen', nullable=False)


def downgrade():
	# ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('users', 'chat_lastseen')
    op.drop_column('users', 'chat_authorized')
    # ### end Alembic commands ###
