I wonder if there is any possibility of data destruction / corruption in the database or database structure if I change something in the model and make migrations. For example if I add some relations to existing fields in tables or new columns? In my projects my django software is installed in local servers and when I make upgrade version (example add new functionality) I often wondering what can go wrong or is there risk of lost data?
It depends upon what exactly you mean by “data destruction / corruption”.
Obviously, if you remove a model, the corresponding migration will cause the table to be dropped.
Migrations aren’t magic. They create a set of SQL statements to be executed by the database server. The risk involved with migrations is no different than that exposed by any other SQL command being issued on the database.
If you have questions on what will be run for any migration, the sqlmigrate
command will show you what SQL statements will be executed for any give migration.