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

629
Visualizações
Django migrations are not applied to database

A bit of backgound: We use docker container to run our django project and since there are a number of us working on the project we have put migrations folder into gitignore (whether this is right or wrong is a separate matter) to avoid merge conflicts.

Everytime makemigrations are run - it's always 001_initial.py as Docker copies the git project which has no migrations in it. It's up to migrate command to figure out which changes to apply to database. It's becoming a common issue now that sometimes when there is a new field (or a field renamed) - although these changes are in myapp\migrations\001_initial.py - once migrate command is run, django thinks those changes are already in the database and it doesn't apply any migrations. We are wiping the database and re-doing the migrations which works fine for development, but obviously it doesn't work for production. There are questions relating to this and people recommended to revert to the previous migrations which seems to reset and worked for us on some occasions - for example:

python manage.py migrate myapp zero

But it doesn't work always if there are relations in database with entirely new tables (so django complains that table doesn't exist) when trying to revert and partly because our migrations in docker container always start from 001_initial.py.

Is this a django bug or are we not following any good practice hence the problem? We are thinking of removing migrations folder from gitignore which enables reverting to older migrations, however we are not entirely sure whether this would fix the issue and besides django project is run in the container - so migrations files inside the container are not commited to git repo.

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

0

I always migrate via the docker composer:

docker-compose run <django-container> python manage.py migrate
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