Django Migrations - what benefits do they bring?
<p>I am pretty sure that <a href="https://docs.djangoproject.com/en/1.10/topics/migrations/" rel="nofollow">Django Migrations</a> bring many benefits to the Django platform. I am just having a hard time identifying those benefits.</p>

<p>Maybe someone could explain to me in what circumstances Django Migrations can be beneficial. In what way does it benefit the work of a software developer?</p>

<p>I could not find that kind of information in the documentation. Maybe it is so obvious that there is no need.</p>

<p>Anyway, thanks in advance for any hint.</p>

<p><strong>Edit:</strong> My apologies for not being accurate enough. The way I wrote above I appear to imply that Django Migrations do not do anything valuable, which is not what I intended.</p>

<p>I know that Django Migrations are meant to keep the database in sync with my Models. What I find annoying is that, sometimes, things go wrong and I have to reset the migrations manually. Still, after your replies I believe I have a better understanding why the Django Migrations are the way they are.</p>

<p>Just as your code changes over time, so does your database layout. Models get new fields, your App gets new models etc.</p>

<p>Your code can be changed and uploaded to your server, replacing old files.</p>

<p>Your database however needs to persistent. You cannot just overwrite your database with a different one and ask 10.000 users to sign up again if you decide your user model needs a new field. Also, every developer in your team has their own database on their machine. The schema of these databases need to be in sync.</p>

<p>Migrations allow you to change your database in a controlled way: Any change you make to your database will be represented in a migration and may be "played back" on a different machine. Some migration systems also support both up and down migrations, allowing migrations to be played forward and backwards (order matters!).</p>

<p>The fact that migrations are part of your codebase makes it easy for them to version tracked and shipped using your usual code deployment method.</p>

<p>Before migrations Django allowed to "sync" your model with your database. This enabled some non-destructive changes in your database. However more complex scenarios in which certain operations need to be done during sync could not be achieved.</p>

<p>Migrations, being Python code, on the other hand allow for custom code to be run during a migration. This allows much more flexible and finely controlled changes in your database.</p>

python django