"""reindex-kernel-updated-order

Revision ID: 48ab2dfefba9
Revises: 0c5733f80e4d
Create Date: 2019-09-24 16:04:29.928068

"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "48ab2dfefba9"
down_revision = "0c5733f80e4d"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index("ix_kernels_updated_order", table_name="kernels")
    op.create_index(
        "ix_kernels_updated_order",
        "kernels",
        [sa.text("greatest('created_at', 'terminated_at', 'status_changed')")],
        unique=False,
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index("ix_kernels_updated_order", table_name="kernels")
    op.create_index(
        "ix_kernels_updated_order",
        "kernels",
        ["created_at", "terminated_at", "status_changed"],
        unique=False,
    )
    # ### end Alembic commands ###
