Django MySQL error when creating tables

后端 未结 11 1524
感动是毒
感动是毒 2020-12-14 01:02

I am building a django app with a MySQL DB. When I run \'python manage.py migrate\' for the first time, some tables are created well then some errors appear. The error broug

11条回答
  •  既然无缘
    2020-12-14 01:29

    I had the same error whilst trying to setup CI in BitBucket/Pipelines. The problem was that I had not committed the migrations folder into our git repository, as Pipelines rebuilds everything from scratch each time, the unit tests were failing to start.

    The migrations folder is created when you execute:

    python manage.py makemigrations
    python manage.py makemigrations 
    

    My tests would work after running the makemigrations/migrate steps and ensuring that our non-test code was working.

    It seems that:

    python manage.py test 
    

    will try to generate the migrations, if they don't currently exist, but it can't always get the dependencies right, hence you need to ensure that you commit the auto-generated code in the migrations folder to your source code repository.

    More details about django migrations can be found here: https://docs.djangoproject.com/en/1.11/topics/migrations/

提交回复
热议问题