"""Update indexes to use new naming conventions

Revision ID: 03e98a49599c
Revises: c0fb4e374830
Create Date: 2020-07-07 13:06:06.204241

"""

from collections.abc import Sequence

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "03e98a49599c"
down_revision: str | None = "c0fb4e374830"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_index(op.f("discounts_currencies_idx"), "discounts", ["currencies"], unique=False)
    op.create_index(op.f("discounts_description_idx"), "discounts", ["description"], unique=False)
    op.create_index(op.f("discounts_id_idx"), "discounts", ["id"], unique=False)
    op.create_index(op.f("discounts_name_idx"), "discounts", ["name"], unique=False)
    op.drop_index("ix_discounts_currencies", table_name="discounts")
    op.drop_index("ix_discounts_description", table_name="discounts")
    op.drop_index("ix_discounts_id", table_name="discounts")
    op.drop_index("ix_discounts_name", table_name="discounts")
    op.create_index(op.f("invoices_id_idx"), "invoices", ["id"], unique=False)
    op.create_index(op.f("invoices_store_id_idx"), "invoices", ["store_id"], unique=False)
    op.drop_index("ix_invoices_id", table_name="invoices")
    op.drop_index("ix_invoices_store_id", table_name="invoices")
    op.create_index(op.f("notifications_id_idx"), "notifications", ["id"], unique=False)
    op.create_index(op.f("notifications_name_idx"), "notifications", ["name"], unique=False)
    op.drop_index("ix_notifications_id", table_name="notifications")
    op.drop_index("ix_notifications_name", table_name="notifications")
    op.create_index(
        op.f("paymentmethods_currency_idx"),
        "paymentmethods",
        ["currency"],
        unique=False,
    )
    op.drop_index("ix_paymentmethods_currency", table_name="paymentmethods")
    op.create_index(op.f("products_id_idx"), "products", ["id"], unique=False)
    op.create_index(op.f("products_name_idx"), "products", ["name"], unique=False)
    op.create_index(op.f("products_store_id_idx"), "products", ["store_id"], unique=False)
    op.drop_index("ix_products_id", table_name="products")
    op.drop_index("ix_products_name", table_name="products")
    op.drop_index("ix_products_store_id", table_name="products")
    op.create_index(op.f("settings_id_idx"), "settings", ["id"], unique=False)
    op.drop_index("ix_settings_id", table_name="settings")
    op.create_index(op.f("stores_domain_idx"), "stores", ["domain"], unique=False)
    op.create_index(op.f("stores_email_idx"), "stores", ["email"], unique=False)
    op.create_index(op.f("stores_id_idx"), "stores", ["id"], unique=False)
    op.create_index(op.f("stores_name_idx"), "stores", ["name"], unique=False)
    op.drop_index("ix_stores_domain", table_name="stores")
    op.drop_index("ix_stores_email", table_name="stores")
    op.drop_index("ix_stores_id", table_name="stores")
    op.drop_index("ix_stores_name", table_name="stores")
    op.create_index(op.f("templates_id_idx"), "templates", ["id"], unique=False)
    op.create_index(op.f("templates_name_idx"), "templates", ["name"], unique=True)
    op.drop_index("ix_templates_id", table_name="templates")
    op.drop_index("ix_templates_name", table_name="templates")
    op.create_index(op.f("tokens_user_id_idx"), "tokens", ["user_id"], unique=False)
    op.drop_index("ix_tokens_user_id", table_name="tokens")
    op.create_index(op.f("users_email_idx"), "users", ["email"], unique=True)
    op.create_index(op.f("users_id_idx"), "users", ["id"], unique=False)
    op.drop_index("ix_users_email", table_name="users")
    op.drop_index("ix_users_id", table_name="users")
    op.create_index(op.f("wallets_currency_idx"), "wallets", ["currency"], unique=False)
    op.create_index(op.f("wallets_id_idx"), "wallets", ["id"], unique=False)
    op.create_index(op.f("wallets_name_idx"), "wallets", ["name"], unique=False)
    op.create_index(op.f("wallets_xpub_idx"), "wallets", ["xpub"], unique=False)
    op.drop_index("ix_wallets_currency", table_name="wallets")
    op.drop_index("ix_wallets_id", table_name="wallets")
    op.drop_index("ix_wallets_name", table_name="wallets")
    op.drop_index("ix_wallets_xpub", table_name="wallets")
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_index("ix_wallets_xpub", "wallets", ["xpub"], unique=False)
    op.create_index("ix_wallets_name", "wallets", ["name"], unique=False)
    op.create_index("ix_wallets_id", "wallets", ["id"], unique=False)
    op.create_index("ix_wallets_currency", "wallets", ["currency"], unique=False)
    op.drop_index(op.f("wallets_xpub_idx"), table_name="wallets")
    op.drop_index(op.f("wallets_name_idx"), table_name="wallets")
    op.drop_index(op.f("wallets_id_idx"), table_name="wallets")
    op.drop_index(op.f("wallets_currency_idx"), table_name="wallets")
    op.create_index("ix_users_id", "users", ["id"], unique=False)
    op.create_index("ix_users_email", "users", ["email"], unique=True)
    op.drop_index(op.f("users_id_idx"), table_name="users")
    op.drop_index(op.f("users_email_idx"), table_name="users")
    op.create_index("ix_tokens_user_id", "tokens", ["user_id"], unique=False)
    op.drop_index(op.f("tokens_user_id_idx"), table_name="tokens")
    op.create_index("ix_templates_name", "templates", ["name"], unique=True)
    op.create_index("ix_templates_id", "templates", ["id"], unique=False)
    op.drop_index(op.f("templates_name_idx"), table_name="templates")
    op.drop_index(op.f("templates_id_idx"), table_name="templates")
    op.create_index("ix_stores_name", "stores", ["name"], unique=False)
    op.create_index("ix_stores_id", "stores", ["id"], unique=False)
    op.create_index("ix_stores_email", "stores", ["email"], unique=False)
    op.create_index("ix_stores_domain", "stores", ["domain"], unique=False)
    op.drop_index(op.f("stores_name_idx"), table_name="stores")
    op.drop_index(op.f("stores_id_idx"), table_name="stores")
    op.drop_index(op.f("stores_email_idx"), table_name="stores")
    op.drop_index(op.f("stores_domain_idx"), table_name="stores")
    op.create_index("ix_settings_id", "settings", ["id"], unique=False)
    op.drop_index(op.f("settings_id_idx"), table_name="settings")
    op.create_index("ix_products_store_id", "products", ["store_id"], unique=False)
    op.create_index("ix_products_name", "products", ["name"], unique=False)
    op.create_index("ix_products_id", "products", ["id"], unique=False)
    op.drop_index(op.f("products_store_id_idx"), table_name="products")
    op.drop_index(op.f("products_name_idx"), table_name="products")
    op.drop_index(op.f("products_id_idx"), table_name="products")
    op.create_index("ix_paymentmethods_currency", "paymentmethods", ["currency"], unique=False)
    op.drop_index(op.f("paymentmethods_currency_idx"), table_name="paymentmethods")
    op.create_index("ix_notifications_name", "notifications", ["name"], unique=False)
    op.create_index("ix_notifications_id", "notifications", ["id"], unique=False)
    op.drop_index(op.f("notifications_name_idx"), table_name="notifications")
    op.drop_index(op.f("notifications_id_idx"), table_name="notifications")
    op.create_index("ix_invoices_store_id", "invoices", ["store_id"], unique=False)
    op.create_index("ix_invoices_id", "invoices", ["id"], unique=False)
    op.drop_index(op.f("invoices_store_id_idx"), table_name="invoices")
    op.drop_index(op.f("invoices_id_idx"), table_name="invoices")
    op.create_index("ix_discounts_name", "discounts", ["name"], unique=False)
    op.create_index("ix_discounts_id", "discounts", ["id"], unique=False)
    op.create_index("ix_discounts_description", "discounts", ["description"], unique=False)
    op.create_index("ix_discounts_currencies", "discounts", ["currencies"], unique=False)
    op.drop_index(op.f("discounts_name_idx"), table_name="discounts")
    op.drop_index(op.f("discounts_id_idx"), table_name="discounts")
    op.drop_index(op.f("discounts_description_idx"), table_name="discounts")
    op.drop_index(op.f("discounts_currencies_idx"), table_name="discounts")
    # ### end Alembic commands ###
