Django manage.py migration related commands not returning anything
I had an issue with migrations in a project I'm working on, a migration was deleted manually and the sync was ruined, I tried a lot of solutions but nothing worked and at the end I decided to backup the DB and delete all migrations and drop the django_migrations
table from the MySQL db, now when I try to run any command like python manage.py makemigrations
or python manage.py migrate
nothing appears in stdout or stderr, absolutely nothing, not even an error, which has been puzzling me
I can provide any information needed but I don't really know where to start here really, Any help would be appreciated a lot.
You need to create
app_name/migrations/__init__.py
for every app you have.
or instead you can run:
python manage.py makemigrations app_name
Look at https://docs.djangoproject.com/en/5.0/ref/django-admin/#inspectdb and https://docs.djangoproject.com/en/5.1/topics/migrations/#adding-migrations-to-apps
I would try the following command for each table and see what its output is for models.py, and then compare the models it creates to the ones you have in your project and correct your project models if needed to match:
python manage.py inspectdb tablename
If running this command doesn't work, there is probably another issue with the database connection. If it works and the models are corrected, you should then run the following:
python manage.py makemigrations
python manage.py migrate --fake-initial
This will make the initial migration but not apply changes because the tables already exist.