Closed isac322 closed 5 years ago
Ah, good catch. I was just working on fixing up schema generation. Will add a test case for safe creation. It should be fixed for 0.13.0 release.
Turns out this issue only reflected on MySQL. It should be fixed on #169
Could you test if that resolved your issue (and everything works fine)?
An easy way would be to pip install https://github.com/tortoise/tortoise-orm/archive/fix_safe_m2m.zip
Thanks it works!
Describe the bug
When creating a table using
Tortoise.generate_schemas()
,IF NOT EXISTS
was not added to the table created bythrough
offields.ManyToManyField
.To Reproduce
just run
and it prints
tortoise.exceptions.OperationalError: (1050, "Table 'event_team' already exists")
And I have found that the generated query is
models.py
(same as example on README of this project)main.py
Expected behavior
IF NOT EXISTS
should be added to the generated query.Additional context
tortoise-orm==0.12.8 aiomysql==0.0.20
MySQL is 8.0.7 Python is 3.7.4