Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.1K
Visualizações
Django migration: django.db.utils.OperationalError: (1824, "Failed to open the referenced table 'classroom_user'")

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
Running migrations:
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.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

OK, solved.
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

over 4 years ago · Santiago Trujillo Relatório

0

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 MyISAM on InnoDB) 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';

Then run migrate again and you're good to go!

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda