tortoise / aerich

A database migrations tool for TortoiseORM, ready to production.
https://github.com/tortoise/aerich
Apache License 2.0
804 stars 90 forks source link

Can't delete m2m relation #312

Open Maksim-Burtsev opened 11 months ago

Maksim-Burtsev commented 11 months ago

I have m2m relation between two tables (and table already exists in the database with default name 'model1_model2'). But after i remove this relation and run aerich migrate i have error:

    return f(get_current_context(), *args, **kwargs)
  File "/Users/zadro/yuco/yuco-backend/venv/lib/python3.10/site-packages/aerich/cli.py", line 31, in wrapper
    loop.run_until_complete(f(*args, **kwargs))
  File "/opt/homebrew/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/Users/zadro/yuco/yuco-backend/venv/lib/python3.10/site-packages/aerich/cli.py", line 86, in migrate
    ret = await command.migrate(name)
  File "/Users/zadro/yuco/yuco-backend/venv/lib/python3.10/site-packages/aerich/__init__.py", line 121, in migrate
    return await Migrate.migrate(name)
  File "/Users/zadro/yuco/yuco-backend/venv/lib/python3.10/site-packages/aerich/migrate.py", line 140, in migrate
    cls.diff_models(cls._last_version_content, new_version_content)
  File "/Users/zadro/yuco/yuco-backend/venv/lib/python3.10/site-packages/aerich/migrate.py", line 243, in diff_models
    table = change[0][1].get("through")
AttributeError: 'str' object has no attribute 'get'

I was tried everything from this issue #150 but nothing helps me.

@long2ice Is it possible to remove this relation by aerich or it will stay forever?

catarium commented 11 months ago

you can install the previous version of aerich (0.7.1)