N
N
NyxDeveloper2021-02-03 14:55:10
Django
NyxDeveloper, 2021-02-03 14:55:10

Migrations created, applied, but their files are missing?

I work with a remote server through pycharm, and in order not to spoil either the database or the migration files, I specifically included them in the deployment exceptions. Everything worked fine, but at some point the server went down and the project had to be reloaded, and the migrations were created and applied on the same server. Now, when adding a new model to the database and calling makemigrations, and then migrate, Django says that nothing has changed in the models and there is nothing to pour into the database. Previously, I solved this by deleting the old database and creating a new one, but now this cannot be done, because the database already has data, A LOT of data.
Can you please tell me if it is possible to fix this error without deleting the old database, but simply somehow let Django know that new migration files need to be created?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alternativshik, 2021-02-03
@NyxDeveloper

so create 1 initial migration with the current state of affairs. Clear the *_migrations tables in the database, Apply it with --fake (nothing will happen). Further, as usual - after changing the models createmigrations, migrate.

D
Dr. Bacon, 2021-02-03
@bacon

Well, it’s standard to sit down once and figure out how they work, read the same docks, then how they can be managed at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question