Everybody Loves Migrations

077e9a0cb34fa3eba2699240c9509717?s=47 Andrew Godwin
September 04, 2013

Everybody Loves Migrations

A talk I gave at DjangoCon US 2013 about Django's new built-in migrations, South 2, and schema alteration.

077e9a0cb34fa3eba2699240c9509717?s=128

Andrew Godwin

September 04, 2013
Tweet

Transcript

  1. 3.
  2. 4.

    What is schema alteration? Background Why wasn't it in Django

    before? Why are you doing all this anyway?
  3. 5.

    Adding a field What is schema alteration? Changing unique_together Setting

    db_index=True Changing the type of a field Renaming a field Setting null=True Adding a model Deleting a model
  4. 6.

    Adding a field What Django did before Changing unique_together Setting

    db_index=True Changing the type of a field Renaming a field Setting null=True Adding a model Deleting a model
  5. 8.
  6. 13.

    Basic Layout schemamigration: Creates migration files in apps datamigration: Also

    creates migration files in apps --auto: No, really, make them for me.
  7. 14.

    Basic Layout schemamigration: Creates migration files in apps datamigration: Also

    creates migration files in apps migrate: Applies migrations only --auto: No, really, make them for me.
  8. 15.

    Basic Layout schemamigration: Creates migration files in apps datamigration: Also

    creates migration files in apps migrate: Applies migrations only syncdb: Does no-migration apps. --auto: No, really, make them for me.
  9. 16.

    Basic Layout schemamigration: Creates migration files in apps datamigration: Also

    creates migration files in apps migrate: Applies migrations only syncdb: Does no-migration apps. Occasionally does migrations. --auto: No, really, make them for me.
  10. 17.

    Basic Layout schemamigration: Creates migration files in apps datamigration: Also

    creates migration files in apps migrate: Applies migrations only syncdb: Does no-migration apps. Occasionally does migrations. --auto: No, really, make them for me. test: Good luck with that one.
  11. 38.

    Compound History Create Model Page with fields content, date Create

    Model Author with fields name, age Add title to Page Remove age from Author Migration 1 Migration 2 Migration 3 Model Page with fields title, content, date Model Author with field name
  12. 40.
  13. 42.
  14. 44.

    Multiple AppCaches If you know what this means, well done.

    Basically, you can make multiple versions of the same model in memory at once.
  15. 46.

    Schema backends PostgreSQL MySQL SQLite Oracle Migration Engine Dependency resolver

    Basic operations makemigrations migrate squashmigrations DONE DONE DONE DONE DONE DONE DONE DONE NOT YET Advanced operations NOT YET Autodetector PARTIAL
  16. 48.

    Don't Panic! syncdb and signals still work Upgrade path from

    South migrations South 2 to backport new format
  17. 49.

    Don't Panic! syncdb and signals still work Upgrade path from

    South migrations South 2 to backport new format Slightly Panic! Custom fields will need some work
  18. 60.

    New migration format Django models through and through Please use

    a proper database Schemas are your friend. Even easier to use