"""empty message

Revision ID: 21ad9cf25fea
Revises: 3c34aab4db16
Create Date: 2022-02-14 13:13:49.020891

"""
import datetime

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '21ad9cf25fea'
down_revision = '3c34aab4db16'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('devices', sa.Column('device_name', sa.String(), nullable=True))
    op.add_column('devices', sa.Column('last_active', sa.DateTime(), nullable=True))
    device_name = sa.table('devices', sa.column('device_name'))
    last_active = sa.table('devices', sa.column('last_active'))
    op.execute(device_name.update().values(device_name="Unknown Device"))
    op.execute(last_active.update().values(last_active=datetime.datetime.utcnow()))
    op.alter_column('devices', 'device_name', nullable=False)
    op.alter_column('devices', 'last_active', nullable=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('devices', 'last_active')
    op.drop_column('devices', 'device_name')
    # ### end Alembic commands ###
