"""Insert theme_info_link resource type

Revision ID: 8c5ebe688265
Revises: e9c31b610e0a
Create Date: 2020-08-13 11:00:54.732613

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '8c5ebe688265'
down_revision = 'e9c31b610e0a'
branch_labels = None
depends_on = None


def upgrade():
    sql = sa.sql.text("""
        INSERT INTO qwc_config.resource_types (name, description, list_order)
          VALUES (
            'theme_info_link', 'Theme info link',
            (SELECT MAX(list_order) + 1 FROM qwc_config.resource_types)
          );
    """)

    conn = op.get_bind()
    conn.execute(sql)


def downgrade():
    sql = sa.sql.text("""
        DELETE FROM qwc_config.resource_types WHERE name = 'theme_info_link';
    """)

    conn = op.get_bind()
    conn.execute(sql)
