"""Add qcengine to required programs

Revision ID: b1d1a21895ba
Revises: 97e1d19796c7
Create Date: 2022-07-07 09:17:33.447320

"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "b1d1a21895ba"
down_revision = "97e1d19796c7"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.execute(sa.text("UPDATE task_queue SET required_programs = ARRAY['qcengine'] || required_programs"))
    op.execute(
        sa.text(
            """UPDATE compute_manager SET programs = programs::jsonb || jsonb_build_object('qcengine', qcengine_version)"""
        )
    )
    op.drop_column("compute_manager", "qcengine_version")
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    raise RuntimeError("Cannot downgrade")
    # ### end Alembic commands ###
