# Copyright (C) 2020 Bloomberg LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#  <http://www.apache.org/licenses/LICENSE-2.0>
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""add bots table

Revision ID: fcb6e8f09a1d
Revises: b57c30a687fa
Create Date: 2023-06-07 11:10:58.114752

"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "fcb6e8f09a1d"
down_revision = "b57c30a687fa"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "bots",
        sa.Column("name", sa.String(), nullable=False),
        sa.Column("bot_id", sa.String(), nullable=False),
        sa.Column("last_update_timestamp", sa.DateTime(), nullable=False),
        sa.Column("bot_status", sa.Integer(), nullable=False),
        sa.Column("lease_id", sa.String(), nullable=True),
        sa.Column("instance_name", sa.String(), nullable=True),
        sa.PrimaryKeyConstraint("name"),
    )
    op.create_index(op.f("ix_bots_bot_id"), "bots", ["bot_id"], unique=False)
    op.create_index(op.f("ix_bots_last_update_timestamp"), "bots", ["last_update_timestamp"], unique=False)
    op.create_index(op.f("ix_bots_name"), "bots", ["name"], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f("ix_bots_name"), table_name="bots")
    op.drop_index(op.f("ix_bots_last_update_timestamp"), table_name="bots")
    op.drop_index(op.f("ix_bots_bot_id"), table_name="bots")
    op.drop_table("bots")
    # ### end Alembic commands ###
