bartTC / django-eventlog

django-eventlog is a very simple event logger you can use to track certain actions in your code. Events are stored in a Django model and can be viewed in the Django Admin.
https://barttc.github.io/django-eventlog/
MIT License
32 stars 5 forks source link

Missing migration #11

Closed mattburlage closed 11 months ago

mattburlage commented 1 year ago

Hello!

It looks like there is a missing migration causing this error when running manage.py migrate

Your models in app(s): 'eventlog' have changes that are not yet reflected in a migration, and so won't be applied. Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

bartTC commented 11 months ago

Hrm, not seeing anything here n the list.

❯ django-admin makemigrations --dry-run
No changes detected

If you feel this is still valid, please reopen the ticket and provide the used Python, Django and eventlog version.

mattburlage commented 6 months ago

Sorry I missed your response. I just started a new Django project, installed django-eventlog, and it still needed the additional migration:

(.venv) user@computer djangoProject % pip install django-eventlog
Collecting django-eventlog
  Using cached django_eventlog-1.3-py2.py3-none-any.whl.metadata (3.9 kB)
Requirement already satisfied: django>=3.2 in ./.venv/lib/python3.12/site-packages (from django-eventlog) (5.0.3)
Requirement already satisfied: asgiref<4,>=3.7.0 in ./.venv/lib/python3.12/site-packages (from django>=3.2->django-eventlog) (3.7.2)
Requirement already satisfied: sqlparse>=0.3.1 in ./.venv/lib/python3.12/site-packages (from django>=3.2->django-eventlog) (0.4.4)
Using cached django_eventlog-1.3-py2.py3-none-any.whl (13 kB)
Installing collected packages: django-eventlog
Successfully installed django-eventlog-1.3
(.venv) user@computer djangoProject % python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, eventlog, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying eventlog.0001_initial... OK
  Applying sessions.0001_initial... OK
(.venv) user@computer djangoProject % python manage.py makemigrations
Migrations for 'eventlog':
  .venv/lib/python3.12/site-packages/eventlog/migrations/0002_alter_event_id.py
    - Alter field id on event
mattburlage commented 6 months ago

@bartTC Please see above. Thanks!

mattburlage commented 6 months ago

This has to do with the Django DEFAULT_AUTO_FIELD default setting, which changed in Django 3.2. This could be resolved by adding default_auto_field = "django.db.models.AutoField" in eventlog/apps.py.

PR: https://github.com/bartTC/django-eventlog/pull/18

bartTC commented 6 months ago

I am not able to replicate that. b7d9d938d50859ea3a8d3c12b0ca0f339dc52875 adds a test to specifically check for missing migrations. I've added it nontheless. Thank you.

mattburlage commented 6 months ago

Thanks!