arteria / django-openinghours

Allows to define opening hours and to verify if something, for example a store, is currently open.
MIT License
57 stars 38 forks source link

makemigrations fail after setting OPENINGHOURS_PREMISES_MODEL #25

Open apekatten opened 7 years ago

apekatten commented 7 years ago
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 commented 6 years ago

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 commented 4 years ago

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