mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #13642: Move migration logic overrides from individual mgmt commands to core
This commit is contained in:
@ -1,4 +1,15 @@
|
|||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
from django.db import models
|
||||||
|
from django.db.migrations.operations import AlterModelOptions
|
||||||
|
|
||||||
|
from utilities.migration import custom_deconstruct
|
||||||
|
|
||||||
|
# Ignore verbose_name & verbose_name_plural Meta options when calculating model migrations
|
||||||
|
AlterModelOptions.ALTER_OPTION_KEYS.remove('verbose_name')
|
||||||
|
AlterModelOptions.ALTER_OPTION_KEYS.remove('verbose_name_plural')
|
||||||
|
|
||||||
|
# Use our custom destructor to ignore certain attributes when calculating field migrations
|
||||||
|
models.Field.deconstruct = custom_deconstruct
|
||||||
|
|
||||||
|
|
||||||
class CoreConfig(AppConfig):
|
class CoreConfig(AppConfig):
|
||||||
|
@ -1,18 +1,6 @@
|
|||||||
# noinspection PyUnresolvedReferences
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.management.base import CommandError
|
from django.core.management.base import CommandError
|
||||||
from django.core.management.commands.makemigrations import Command as _Command
|
from django.core.management.commands.makemigrations import Command as _Command
|
||||||
from django.db import models
|
|
||||||
from django.db.migrations.operations import AlterModelOptions
|
|
||||||
|
|
||||||
from utilities.migration import custom_deconstruct
|
|
||||||
|
|
||||||
# Monkey patch AlterModelOptions to ignore verbose name attributes
|
|
||||||
AlterModelOptions.ALTER_OPTION_KEYS.remove('verbose_name')
|
|
||||||
AlterModelOptions.ALTER_OPTION_KEYS.remove('verbose_name_plural')
|
|
||||||
|
|
||||||
# Set our custom deconstructor for fields
|
|
||||||
models.Field.deconstruct = custom_deconstruct
|
|
||||||
|
|
||||||
|
|
||||||
class Command(_Command):
|
class Command(_Command):
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
# noinspection PyUnresolvedReferences
|
|
||||||
from django.core.management.commands.migrate import Command
|
|
||||||
from django.db import models
|
|
||||||
|
|
||||||
from utilities.migration import custom_deconstruct
|
|
||||||
|
|
||||||
models.Field.deconstruct = custom_deconstruct
|
|
Reference in New Issue
Block a user