Opened 14 years ago

Last modified 13 years ago

#25 new task

Investigate South's resilience to failed migrations

Reported by: geofft Owned by:
Priority: normal Milestone: Sometime
Component: Infrastructure Version:
Keywords: Cc:
Size: medium

Description

We've seen that it's possible for South to silently ignore some migrations and carry on to future migrations (in particular see r31e4eaa4e417aa48ec6bcff79f4e792abf7a7763). We don't currently understand in perfect detail how South searches for valid migration files, and stores its current state.

It would be nice to ensure that if someone botches a migration, or if South changes in some backwards-incompatible way, manage.py won't attempt migrations out of order (because on our current database server, South goes "sorry, would you like to drop the DB and try again?", which isn't particularly practical).

Change History (7)

comment:1 follow-up: Changed 14 years ago by adehnert

FWIW, http://south.aeracode.org/ticket/570#comment:12 is vaguely relevant here: IIRC, Django South does not store ordering of migrations in different apps. This can be an issue if you have changes that depend on each other. This mostly works if you run the migrations a couple times... They'll usually eventually finish successfully...

comment:2 Changed 14 years ago by adehnert

Ah, okay, so the current code finds migration files as follows:

    if getattr(settings, "SOUTH_USE_PYC", False):
        MIGRATION_FILENAME = re.compile(r'(?!__init__)' # Don't match __init__.py
                                        r'[0-9a-zA-Z_]*' # Don't match dotfiles, or names with dots/invalid chars in them
                                        r'(\.pyc?)?$')     # Match .py or .pyc files, or module dirs
    else:
        MIGRATION_FILENAME = re.compile(r'(?!__init__)' # Don't match __init__.py
                                        r'[0-9a-zA-Z_]*' # Don't match dotfiles, or names with dots/invalid chars in them
                                        r'(\.py)?$')       # Match only .py files, or module dirs

I can't *really* imagine that regexp getting much more restrictive, so I don't foresee a repeat of the problematic commit that Geoff pointed out above.

comment:3 Changed 14 years ago by adehnert

(Oh, also, South appears to yell now if you have a badly named migration, so we also won't have people screwing that one up.)

comment:4 in reply to: ↑ 1 Changed 14 years ago by adehnert

Replying to adehnert:

FWIW, http://south.aeracode.org/ticket/570#comment:12 is vaguely relevant here: IIRC, Django South does not store ordering of migrations in different apps. This can be an issue if you have changes that depend on each other. This mostly works if you run the migrations a couple times... They'll usually eventually finish successfully...

Huh, neat, apparently South supports dependencies. We should try to habitually use dependencies between our apps (forms and groups). Relevant docs are at http://south.aeracode.org/docs/dependencies.html.

There's also a "migrationcheck" command in the South repo, though I don't think it's released yet. It claims that our migrations are fine, though I'm not sure I believe it. OTOH, running "./manage.py syncdb; ./manage.py migrate" on a new checkout seemed to work fine, so maybe it's not on crack.

comment:5 Changed 14 years ago by adehnert

Pushing upstream to implement http://south.aeracode.org/ticket/509 (by which I probably mean "implement it ourself and get it accepted") may also be productive, since it'll make it easier to maintain dependency information.

comment:6 Changed 14 years ago by adehnert

  • Component changed from Default to Core
  • Size set to medium

comment:7 Changed 13 years ago by adehnert

  • Component changed from Core to Infrastructure
Note: See TracTickets for help on using tickets.