Migrations from my Django app are not applied

Asked

Viewed 20 times

0

I created the models.py file in my app, created all the models, added appConfig to INSTALLED_APPS but when I use the manage.py migrate myapp it does not make any changes to the mysql database:

inserir a descrição da imagem aqui

Can you help me?

1 answer

0

By the way you described the problem you created the new app (using the nomenclature of Django) myapp in the "hand".

When the correct would be to use the command provided by Django.

python manage.py startapp <nome_do_modulo>

Which you should use next time.

To solve this specific problem you must "copy" the structure that would be generated when executing the above command.

Specifically the fact of not generating the Migrations is due to the fact that there is no directory migrations/, also inside the directory migrations there must be a file __init__.py.

To solve your problem by porting just create this structure quoted, after this it will be possible to run the migrations.

In addition to generating the Migrations you must execute the command:

python manage.py makemigrations

Because it will generate the diff (check the structure of tables present today in your database, and generate the difference (increment) based on what exists in models).

Follows the reference about how this command works.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.