Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

makemigrations fail after setting OPENINGHOURS_PREMISES_MODEL #25

Open
apekatten opened this issue Jul 15, 2017 · 2 comments · May be fixed by #41
Open

makemigrations fail after setting OPENINGHOURS_PREMISES_MODEL #25

apekatten opened this issue Jul 15, 2017 · 2 comments · May be fixed by #41

Comments

@apekatten
Copy link

apekatten commented Jul 15, 2017

apekatten@dev01:~/djangoproject$ python3 manage.py makemigrations
Migrations for 'openinghours':
  /usr/local/lib/python3.5/dist-packages/openinghours/migrations/0002_auto_20170715_0103.py
    - Create model Company
    - Change Meta options on closingrules
    - Change Meta options on openinghours
    - Alter field company on closingrules
    - Alter field end on closingrules
    - Alter field reason on closingrules
    - Alter field start on closingrules
    - Alter field company on openinghours
    - Alter field from_hour on openinghours
    - Alter field to_hour on openinghours
    - Alter field weekday on openinghours
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.5/dist-packages/django/core/management/commands/makemigrations.py", line 193, in handle
    self.write_migration_files(changes)
  File "/usr/local/lib/python3.5/dist-packages/django/core/management/commands/makemigrations.py", line 232, in write_migration_files
    with io.open(writer.path, "w", encoding='utf-8') as fh:
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/openinghours/migrations/0002_auto_20170715_0103.py'
@carlastabile
Copy link

I have this issue as well. The error shown is;

django.db.utils.ProgrammingError: relation "openinghours_company" does not exist

when running python manage.py migrate openinghours

@fmalina
Copy link
Contributor

fmalina commented Dec 15, 2019

My migrations fail like this:

Traceback (most recent call last):
  File "./manage.py", line 8, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 328, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 369, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 189, in handle
    pre_migrate_state = executor._create_project_state(with_applied_migrations=True)
  File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 79, in _create_project_state
    migration.mutate_state(state, preserve=False)
  File "/usr/local/lib/python3.7/site-packages/django/db/migrations/migration.py", line 87, in mutate_state
    operation.state_forwards(self.app_label, new_state)
  File "/usr/local/lib/python3.7/site-packages/django/db/migrations/operations/fields.py", line 229, in state_forwards
    state.models[app_label, self.model_name_lower].fields
KeyError: ('openinghours', 'company')

I introduced the OPENINGHOURS_PREMISES_MODEL and back then the migrations worked I think, grumble, grumble.

@imposeren I see swappable is undocumented now for just over 7 years https://code.djangoproject.com/ticket/19103
could this save us https://github.com/wq/django-swappable-models

@fmalina fmalina linked a pull request Dec 16, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants