Upgrade to Pro — share decks privately, control downloads, hide ads and more …

South New and Old

South New and Old

A talk I gave at DjangoCon Europe 2010

Andrew Godwin

May 25, 2010
Tweet

More Decks by Andrew Godwin

Other Decks in Programming

Transcript

  1. new and old
    south
    Andrew Godwin
    djangocon.eu 2010

    View full-size slide

  2. It's been almost 2 years.
    Lots has happened.

    View full-size slide

  3. Migrations? Eh?
    A bit like a VCS, but for database schemas.

    View full-size slide

  4. The Beginning

    View full-size slide

  5. 1-make_tables.sql
    2-add_profile.sql

    View full-size slide

  6. YOU ARE AT
    VERSION
    2
    1-make_tables.sql
    2-add_profile.sql

    View full-size slide

  7. 1-make_tables.sql
    2-add_profile.sql
    3-remove_pony.sql
    1-make_tables.sql
    2-add_profile.sql
    4-add_postcode.sql

    View full-size slide

  8. 1-make_tables.sql
    2-add_profile.sql
    3-remove_pony.sql
    1-make_tables.sql
    2-add_profile.sql
    4-add_postcode.sql
    YOU ARE AT
    VERSION
    3 YOU ARE AT
    VERSION
    4

    View full-size slide

  9. 1-make_tables.sql
    2-add_profile.sql
    3-remove_pony.sql
    1-make_tables.sql
    2-add_profile.sql
    4-add_postcode.sql
    YOU ARE AT
    VERSION
    3 YOU ARE AT
    VERSION
    4
    3-remove_pony.sql
    4-add_postcode.sql

    View full-size slide

  10. Oracle MySQL
    PostgreSQL
    MSSQL
    SQLite

    View full-size slide

  11. The Early Days

    View full-size slide

  12. Adding tables
    Deleting tables
    Everything else useful

    View full-size slide

  13. 3-remove_pony.sql
    1-make_tables.sql
    2-add_profile.sql
    4-add_postcode.sql

    View full-size slide

  14. Uh-oh, publicity

    View full-size slide

  15. Closing this, as it's unlikely we'll write a
    model history tracker in the near future,
    and django-evolution does this well -
    no need to reinvent the wheel in that area.


    View full-size slide

  16. Feature Creep
    (of the good sort)

    View full-size slide

  17. start_field_re = re.compile(r'\s*%s\s*=\s*(.*)' % field.name)
    for line in source[0]:
    # if the field was found during a previous iteration,
    # we're here because the field spans across multiple lines
    # append the current line and try again

    View full-size slide

  18. cms.0001_initial
    cms.0002_auto_start
    picture.0001_initial
    file.0001_initial
    flash.0001_initial
    link.0001_initial
    snippet.0001_initial
    video.0001_initial twitter.0001_initial
    cms.0003_remove_placeholder
    cms.0004_textobjects
    cms.0005_mptt_added_to_plugins
    cms.0006_apphook
    text.0001_initial cms.0007_apphook_longer
    cms.0008_redirects
    cms.0009_added_meta_fields
    cms.0010_5char_language
    cms.0011_title_overwrites
    cms.0012_publisher
    cms.0013_site_copy
    file.0003_publisher
    text.0003_publisher
    picture.0004_publisher
    googlemap.0001_initial
    link.0005_publisher
    flash.0003_publisher
    snippet.0002_publisher
    cms.0014_sites_removed
    cms.0015_modified_by_added
    cms.0016_author_copy
    cms.0017_author_removed
    cms.0018_site_permissions
    cms.0019_public_table_renames
    file.0004_table_rename
    cms.0020_advanced_permissions
    picture.0006_float_added teaser.0001_initial
    text.0004_table_rename
    flash.0004_table_rename link.0006_table_rename snippet.0003_table_rename
    googlemap.0002_table_rename
    picture.0005_table_rename
    cms.0021_publisher2
    picture.0007_publisher2
    cms.0022_login_required_added
    teaser.0002_publisher2
    cms.0023_plugin_table_naming_function_changed
    text.0002_freeze
    text.0005_publisher2
    picture.0002_link_rename
    picture.0003_freeze
    picture.0008_longdesc_added
    file.0002_freeze
    file.0005_publisher2
    flash.0002_freeze
    flash.0005_publisher2
    link.0002_link_rename
    link.0003_page_link
    link.0004_larger_link_names
    link.0007_publisher2
    link.0008_mailto
    snippet.0004_publisher2
    snippet.0005_template_added
    googlemap.0006_publisher2
    googlemap.0007_latlng
    googlemap.0008_routeplaner
    googlemap.0009_routeplaner_title
    video.0002_color_mute_controller
    video.0003_newplayer_step1
    video.0004_newplayer_step2
    video.0005_newplayer_step3
    video.0006_newplayer_step4
    video.0007_newplayer_step5
    inherit.0001_initial
    inherit.0002_fieldchanges

    View full-size slide

  19. Model Freezing

    View full-size slide

  20. Historical ORM access
    Automatic change detection
    ‘Improved’ model parsing

    View full-size slide

  21. Sanity Dawns

    View full-size slide

  22. Introspection
    Magically supports custom fields
    Prevents hideous migration failure

    View full-size slide

  23. SQLite
    Make new table
    Copy data from old table
    Delete old table
    Rename new table

    View full-size slide

  24. Signals
    Speed
    Simplicity

    View full-size slide

  25. MultiDB?
    Non-relational?
    Renames!

    View full-size slide

  26. Organic Growth
    But it's still cleanly separated

    View full-size slide

  27. Database
    Backend
    Dependency/
    Ordering
    Engine
    Migration
    Runner
    Auto-
    detector

    View full-size slide

  28. Database
    Backend
    Dependency/
    Ordering
    Engine
    South in future
    ???
    Migration
    Runner
    Auto-
    detector

    View full-size slide

  29. The Ultimate Goal

    View full-size slide

  30. Andrew Godwin
    Fin.
    www.aeracode.org
    @andrewgodwin

    View full-size slide

  31. Andrew Godwin
    Fin.
    www.aeracode.org
    @andrewgodwin

    View full-size slide