Ticket #819 (closed defect: invalid)

Opened 3 years ago

Last modified 3 years ago

Custom migration paths raises error for empty __init__.py files

Reported by: sr@… Owned by: andrew
Priority: minor Milestone: 1.0
Component: migrations Version: 0.7.3
Keywords: Cc:

Description

Hey everyone.

When using south i alwyas map my apps to custom migration paths. However, by doing so i constantly get "AttributeError?: 'module' object has no attribute 'Migration'" exception because the empty init.py file is searched for migrations too.

My patch is meant as suggestion. What do you think?

Attachments

no_empty_init_files.diff (1.0 KB) - added by sr@… 3 years ago.

Change History

Changed 3 years ago by sr@…

comment:1 Changed 3 years ago by andrew

  • Priority changed from major to minor
  • Status changed from new to infoneeded
  • Milestone set to 1.0

I can't see what your patch achieves; the MIGRATION_FILENAME regex check earlier in that function prevents it from appending init.py in the first place (South has been placing those in migration directories for years).

comment:2 Changed 3 years ago by sr@…

  • Status changed from infoneeded to assigned

Ok, it's a configuration problem: i set my migrations path so all migrations are in the main module. For example, if the django project is called mainapp, it looked something like:

SOUTH_MIGRATION_MODULES = {

'mainapp': 'mainapp.migrations.someapp',

}

In which case south assumes mainapp uses south too and appends the init.py. Even though this is kinda stupid, it think my patch makes still a little bit of sense, because it doesn't hurt and fixes exactly this strange (miss)configuration. For example, i could set:

SOUTH_MIGRATION_MODULES = {

'mainapp': 'ignore',
'mainapp': 'mainapp.migrations.someapp',

}

but if i miss the ignore mainapp line, the mentioned exception jumps around the corner.

I hope i could point out my problem clearly (more or less).

comment:3 Changed 3 years ago by sr@…

By the way: akismet doesn't seem to like foo, bar or baz

comment:4 Changed 3 years ago by sr@…

ignore the last comment, it just doesn't like nearly anything from anonymous :)

comment:5 Changed 3 years ago by andrew

Wait, that's not how you use SOUTH_MIGRATION_MODULES - you can't specify a the project on the left hand side, as it's not an app. It's meant to be appname: location of migration files - what exactly are you trying to do? Move someapp's migrations elsewhere?

comment:6 Changed 3 years ago by sr@…

Ahm, jeah... trying to move someapp migrations somwere else. Sorry, in the example above, i meant:

SOUTH_MIGRATION_MODULES = {
    'someapp': 'mainapp.migrations.someapp',
}

probably i shouldn't post stuff this late...

comment:7 Changed 3 years ago by andrew

Alright, and that causes the exception? Could you post a small example project tar, or something - this information isn't enough for me to replicate the issue.

comment:8 Changed 3 years ago by sr@…

Sorry for the very late answer... lost my attention to this ticket. Ticket can be closed in my opinion. It was PEBKAC in most every way. If you want to have a custom migration path, it's wiser not to include 'migrations' anywhere in the path, as it is misleading anyway. I couldn't even repoduce this in a vanilla django project, only in our specific env.

Anyway, thanks for the support!

comment:9 Changed 3 years ago by andrew

  • Status changed from assigned to closed
  • Resolution set to invalid
Note: See TracTickets for help on using tickets.