#22682 closed Bug (fixed)
Makemigrations fails when specifying custom location for migration files
Reported by: | ovidiuc4 | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | dev |
Severity: | Normal | Keywords: | 1.7b4 |
Cc: | ovidiuc4 | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When running the initial:
python ./manage.py makemigrations appname
a "migrations" directory is automatically created inside the apps base directory.
When specifying a custom migration file location via MIGRATION_MODULES setting, running initial migration fails to create the directories needed for the migration files. One would expect the same behavior in both situations.
In my case, I want to have all the migrations inside a generic folder named "migrations", setup like so:
# in settings: MIGRATION_MODULES = dict([(app, 'migrations.' + app) for app in INSTALLED_APPS]) # running makemigrations python ./manage.py makemigrations appname Traceback (most recent call last): File "./manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/dev/.envs/atlas2/src/django/django/core/management/__init__.py", line 427, in execute_from_command_line utility.execute() File "/home/dev/.envs/atlas2/src/django/django/core/management/__init__.py", line 419, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/dev/.envs/atlas2/src/django/django/core/management/base.py", line 288, in run_from_argv self.execute(*args, **options.__dict__) File "/home/dev/.envs/atlas2/src/django/django/core/management/base.py", line 337, in execute output = self.handle(*args, **options) File "/home/dev/.envs/atlas2/src/django/django/core/management/commands/makemigrations.py", line 54, in handle loader = MigrationLoader(None) File "/home/dev/.envs/atlas2/src/django/django/db/migrations/loader.py", line 47, in __init__ self.build_graph() File "/home/dev/.envs/atlas2/src/django/django/db/migrations/loader.py", line 144, in build_graph self.load_disk() File "/home/dev/.envs/atlas2/src/django/django/db/migrations/loader.py", line 71, in load_disk module = import_module(module_name) File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) ImportError: No module named appname
I would expect the same behavior in both cases, i.e. have the modules automatically created.
Change History (9)
comment:2 by , 11 years ago
Triage Stage: | Unreviewed → Accepted |
---|
Looks reasonable, there's nothing in the docs for MIGRATION_MODULES
that says the directory must already exist.
comment:4 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Update: I manually created the directories, but it ignored them and added the migration files in their default locations for contrib apps (i.e. inside django installation).