whataremigrations.rst 1.3 KB

123456789101112131415161718192021222324252627
  1. .. _what-are-migrations:
  2. What are migrations?
  3. ====================
  4. For the uninitiated, migrations (also known as 'schema evolution' or
  5. 'mutations') are a way of changing your database schema from one version into
  6. another. Django by itself can only do this by adding new models, but nearly all
  7. projects will find themselves changing other aspects of models - be it adding a
  8. new field to a model, or changing a database column to have null=True.
  9. South, and other solutions, provide a way of getting round this by giving you
  10. the tools to easily and predictably upgrade your database schema. You write
  11. migrations, which tell South how to upgrade from one version to the next, and by
  12. stringing these migrations together you can move forwards (or backwards) through
  13. the history of your database schema.
  14. In South, the migrations also form the way of creating your database initially
  15. - the first migration simply migrates from an empty schema to your first tables.
  16. This way, running through all the migrations brings your database up-to-date
  17. with the most current version of the app, and if you already have an older
  18. version, you simply need to run through the ones that appeared since last time.
  19. Running through the :ref:`tutorial <tutorial-part-1>` will give you a good
  20. idea of how migrations work and how they're useful to you, with some
  21. solid examples.