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