ITADN

django.db.utils.OperationalError: (1050, "Table 'bar' already exists")

#378Closedulyssejdv 创建于 2023-07-17
U
ulyssejdvcommented
Hi :) First of all, thank you very much for the package I think it will be very helpfull for the Django community. Unfortunately i encounter some issues :( I'm sure I'm not using it the right way ... There is an example of test I wrote. ```python @pytest.mark.django_db() def test_should_copy_cads_validations_to_validations_demonstrations(migrator): old_state = migrator.apply_initial_migration( ("validations", "0004_auto_20230623_1110") ) # .. create some models here .. new_state = migrator.apply_tested_migration( ("validations", "0005_auto_20230713_1115") ) # After the initial migration is done, we can use the model state: Bar = new_state.apps.get_model("foo", "Bar") # .. some assert here .. ``` When I execute this test I have the folloing error : django.db.utils.OperationalError: (1050, "Table 'foo_bar' already exists") When i stop on a breakpoint in debug mode in my IDE, there are table already created before apply_initial_migration was called (the error source I think) but I don't understand why tables are already present. I execute this test in total isolation, make this there is no table in the DB. If you have an idea, I will really appreciate :) I use a MySQL 5.7, python 3.9, Django 3.2
关闭于 2023-08-03 6 条评论