I am trying to deploy a Django app from a development server to a production server
I have set up a virtualenv with python 3.8.10, created the mysql database, I am running in the virtualenv. I get no errors from
python manage.py check, get "no changes detected" when running
python manage.py makemigrations, but when I run ```python manage.py migrate`` I get the following:
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Applying contenttypes.0001_initial... OK
Applying admin.0001_initial...Traceback (most recent call last):...
final line of the traceback:
Django.db.utils.OperationalError: (1824, "Failed to open the referenced table 'classroom_user'")
("classroom" is the name of the app within the project "codex") I just recently rebuilt all of the tables in this database on my development server with no issues.
The database on the production server is empty. models.py is in place and complete. I have tried it both with an empty migrations folder and the migration folder removed. The migration does create django_admin_log, django_content_types, django_migrations, but no other tables.
All of the other posts I have seen on this have been about have foreign key constraints, but in my models.py all of the tables that have foreign keys are specified after the tables where the keys are.
I was able to get a different error with a slightly older version of Django (3.2.6 instead of 3.2.8) and on a Windows server instead of Linux. This gave me an error regarding foreign key restraints that I have seen in other posts, but was not an error I had seen before.
I had to perform the migrations for my app first (where classroom is the app within the project.):
python manage.py makemigrations classroom
python manage.py migrate
This worked for me! Try to check your table ENGINE with this command:
MySQL: SHOW TABLE STATUS WHERE NAME='XXX';
Then find its Engine (It's either
After that, change the engine of your newly created table (which throw the error) and match it with your
classroom_user table with this command:
MySQL: ALTER TABLE classroom_user ENGINE='XXXX';
migrate again and you're good to go!