Answer the question
In order to leave comments, you need to log in
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
migrate does not delete data unless you explicitly write such a migration, well, what exactly are you doing there, we do not know
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 questionAsk a Question
731 491 924 answers to any question