makemigrations.py 1.1 KB

12345678910111213141516171819202122232425262728
  1. # noinspection PyUnresolvedReferences
  2. from django.conf import settings
  3. from django.core.management.base import CommandError
  4. from django.core.management.commands.makemigrations import Command as _Command
  5. from django.db import models
  6. from . import custom_deconstruct
  7. models.Field.deconstruct = custom_deconstruct
  8. class Command(_Command):
  9. def handle(self, *args, **kwargs):
  10. """
  11. This built-in management command enables the creation of new database schema migration files, which should
  12. never be required by and ordinary user. We prevent this command from executing unless the configuration
  13. indicates that the user is a developer (i.e. configuration.DEVELOPER == True).
  14. """
  15. if not settings.DEVELOPER:
  16. raise CommandError(
  17. "This command is available for development purposes only. It will\n"
  18. "NOT resolve any issues with missing or unapplied migrations. For assistance,\n"
  19. "please post to the NetBox mailing list:\n"
  20. " https://groups.google.com/forum/#!forum/netbox-discuss"
  21. )
  22. super().handle(*args, **kwargs)