N
N
NyxDeveloper2021-01-26 10:19:11
Django
NyxDeveloper, 2021-01-26 10:19:11

Why does django makemigrations delete objects in the database?

I’m switching from sqlite3 to Postgres, doing a transfer from the old database to the new one, since some models have changed, it was necessary to apply migrations, but with each makemigrations/migrate, absolutely all objects from the new database that were previously uploaded are deleted. I work on a remote server via SFTP, I don’t understand what’s wrong, because the code on the server is completely identical. What could be wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dr. Bacon, 2021-01-26
@bacon

migrate does not delete data unless you explicitly write such a migration, well, what exactly are you doing there, we do not know

N
NyxDeveloper, 2021-01-26
@NyxDeveloper

If you work through a remote connection in PyCharm and do not disable automatic database upload to the server when creating and applying migrations, then along with all changes in the code, an empty database will be uploaded to the server, since PyCharm perceives it as a modified file. Therefore, when working with a remote server, you should apply migrations in the terminal of your ssh session.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question