Skip to content

TypeError: drop_index() takes 2 positional arguments but 3 were given #1243

Description

@bobbypriam

Describe the bug
Upgrading from 1.10.4 to 1.11.0 breaks existing migration, possibly due to this change: #1130

Expected behavior
Existing migration still works, or a deprecation warning with clear migration path is given.

To Reproduce
Please try to provide a Minimal, Complete, and Verifiable example, with the migration script and/or the SQLAlchemy tables or models involved.
See also Reporting Bugs on the website.

"""dummy revision

Revision ID: cc20a95c17c5
Revises:
Create Date: 2023-05-16 13:41:28.641085

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'cc20a95c17c5'
down_revision = None
branch_labels = None
depends_on = None


def upgrade() -> None:
    # This worked on 1.10.4, but broke on 1.11.0
    op.drop_index("dummy_index_name", "dummy_table_name")
    pass


def downgrade() -> None:
    pass

Error

➵  alembic upgrade head
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> cc20a95c17c5, dummy revision
Traceback (most recent call last):
  File "/Users/<user>/Work/alembic-test/.venv/bin/alembic", line 8, in <module>
    sys.exit(main())
  File "/Users/<user>/Work/alembic-test/.venv/lib/python3.10/site-packages/alembic/config.py", line 617, in main
    CommandLine(prog=prog).main(argv=argv)
  File "/Users/<user>/Work/alembic-test/.venv/lib/python3.10/site-packages/alembic/config.py", line 611, in main
    self.run_cmd(cfg, options)
  File "/Users/<user>/Work/alembic-test/.venv/lib/python3.10/site-packages/alembic/config.py", line 588, in run_cmd
    fn(
  File "/Users/<user>/Work/alembic-test/.venv/lib/python3.10/site-packages/alembic/command.py", line 385, in upgrade
    script.run_env()
  File "/Users/<user>/Work/alembic-test/.venv/lib/python3.10/site-packages/alembic/script/base.py", line 582, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/Users/<user>/Work/alembic-test/.venv/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 94, in load_python_file
    module = load_module_py(module_id, path)
  File "/Users/<user>/Work/alembic-test/.venv/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 110, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/<user>/Work/alembic-test/alembic/env.py", line 78, in <module>
    run_migrations_online()
  File "/Users/<user>/Work/alembic-test/alembic/env.py", line 72, in run_migrations_online
    context.run_migrations()
  File "<string>", line 8, in run_migrations
  File "/Users/<user>/Work/alembic-test/.venv/lib/python3.10/site-packages/alembic/runtime/environment.py", line 928, in run_migrations
    self.get_context().run_migrations(**kw)
  File "/Users/<user>/Work/alembic-test/.venv/lib/python3.10/site-packages/alembic/runtime/migration.py", line 628, in run_migrations
    step.migration_fn(**kw)
  File "/Users/<user>/Work/alembic-test/alembic/versions/cc20a95c17c5_dummy_revision.py", line 20, in upgrade
    op.drop_index("dummy_index_name", "dummy_table_name")
  File "<string>", line 8, in drop_index
TypeError: drop_index() takes 2 positional arguments but 3 were given

Versions.

  • OS: macOS 13.3.1 (22E261) - also get same error in Docker
  • Python: Python 3.10.10
  • Alembic: alembic==1.11.0
  • SQLAlchemy: SQLAlchemy==2.0.13
  • Database: MySQL
  • DBAPI: PyMySQL==1.0.3

Additional context

Have a nice day!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions