Migration 0016_replicate_interfaces fails due to null value #4025

Closed
opened 2025-12-29 18:32:40 +01:00 by adam · 7 comments
Owner

Originally created by @tmpkn on GitHub (Aug 25, 2020).

Environment

  • Python version: 3.6.8
  • NetBox version: master (git)
  • Postgresql version: 9.6

Steps to Reproduce

  1. sudo -u netbox venv/bin/python3 netbox/manage.py migrate
    (or using the upgrade.sh)

Expected Behavior

Complete the upgrade and DB migrations.

Observed Behavior

Applying virtualization.0016_replicate_interfaces...
    Replicating 16 VM interfaces...
Traceback (most recent call last):
  File "/opt/netbox/venv/lib64/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.NotNullViolation: null value in column "mode" violates not-null constraint
DETAIL:  Failing row contains (2, eth0, 9999999999999999eth000000............, t, 00:0c:29:xx:xx:xx, null, null, , null, 11).
Originally created by @tmpkn on GitHub (Aug 25, 2020). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report, and that any plugins have been disabled. --> ### Environment * Python version: 3.6.8 * NetBox version: master (git) * Postgresql version: 9.6 <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox. Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a client library such as pynetbox. --> ### Steps to Reproduce 1. sudo -u netbox venv/bin/python3 netbox/manage.py migrate (or using the upgrade.sh) <!-- What did you expect to happen? --> ### Expected Behavior Complete the upgrade and DB migrations. <!-- What happened instead? --> ### Observed Behavior ``` Applying virtualization.0016_replicate_interfaces... Replicating 16 VM interfaces... Traceback (most recent call last): File "/opt/netbox/venv/lib64/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) psycopg2.errors.NotNullViolation: null value in column "mode" violates not-null constraint DETAIL: Failing row contains (2, eth0, 9999999999999999eth000000............, t, 00:0c:29:xx:xx:xx, null, null, , null, 11). ```
adam added the type: bugstatus: accepted labels 2025-12-29 18:32:40 +01:00
adam closed this issue 2025-12-29 18:32:40 +01:00
Author
Owner

@tmpkn commented on GitHub (Aug 25, 2020):

Solved by changing the migration line to:

mode=interface.mode or 'Access'

@tmpkn commented on GitHub (Aug 25, 2020): Solved by changing the migration line to: `mode=interface.mode or 'Access'`
Author
Owner

@jeremystretch commented on GitHub (Aug 26, 2020):

Thank you for opening a bug report. I was unable to reproduce the reported behavior on NetBox v2.9.1. Please re-confirm the reported behavior on the current stable release and adjust your post above as necessary. Remember to provide detailed steps that someone else can follow using a clean installation of NetBox to reproduce the issue. Remember to include the steps taken to create any initial objects or other data.

@jeremystretch commented on GitHub (Aug 26, 2020): Thank you for opening a bug report. I was unable to reproduce the reported behavior on NetBox v2.9.1. Please re-confirm the reported behavior on the current stable release and adjust your post above as necessary. Remember to provide detailed steps that someone else can follow using a clean installation of NetBox to reproduce the issue. Remember to include the steps taken to create any initial objects or other data.
Author
Owner

@clienthax commented on GitHub (Aug 26, 2020):

@jeremystretch It needs to be a database with virtual interfaces from a older version of netbox, eg 2.5.11, going directly to 2.9.1 will reproduce the error.
If you go to 2.8.5 then 2.9.1 it doesn't however reproduce it and data is present.

@clienthax commented on GitHub (Aug 26, 2020): @jeremystretch It needs to be a database with virtual interfaces from a older version of netbox, eg 2.5.11, going directly to 2.9.1 will reproduce the error. If you go to 2.8.5 then 2.9.1 it doesn't however reproduce it and data is present.
Author
Owner

@jeremystretch commented on GitHub (Aug 27, 2020):

@clienthax I'm afraid that's not sufficient detail to reproduce the issue.

@jeremystretch commented on GitHub (Aug 27, 2020): @clienthax I'm afraid that's not sufficient detail to reproduce the issue.
Author
Owner

@nward commented on GitHub (Aug 28, 2020):

I am hitting this issue, moving from v2.5.12 to v2.9.2.

In dcim.0082_3569_interface_fields interface.mode type changes from models.PositiveSmallIntegerField to models.CharField. In doing so, it sets default = '', so any null mode values become empty string.

In my setup, it's trying to run virtualization.0016_replicate_interfaces prior to running the above migration, and copy dcim_interface.mode (smallint, null ok) directly to virtualization_vminterface.mode (char, not null).

If we are able to run dcim.0082_3569_interface_fields prior to virtualization.0016_replicate_interfaces then this problem goes away - and presumably interim versions of netbox @clienthax mentioned 2.8.5 has the former but not the latter.

I'm submitting a PR to fix this now.

@nward commented on GitHub (Aug 28, 2020): I am hitting this issue, moving from v2.5.12 to v2.9.2. In `dcim.0082_3569_interface_fields` `interface.mode` type changes from `models.PositiveSmallIntegerField` to `models.CharField`. In doing so, it sets `default = ''`, so any null `mode` values become empty string. In my setup, it's trying to run `virtualization.0016_replicate_interfaces` prior to running the above migration, and copy `dcim_interface.mode` (smallint, null ok) directly to `virtualization_vminterface.mode` (char, not null). If we are able to run `dcim.0082_3569_interface_fields` prior to `virtualization.0016_replicate_interfaces` then this problem goes away - and presumably interim versions of netbox @clienthax mentioned 2.8.5 has the former but not the latter. I'm submitting a PR to fix this now.
Author
Owner

@nward commented on GitHub (Aug 29, 2020):

Steps to reproduce. The following is done in netbox-docker - however this issues also presents outside of docker - I'm using docker here to avoid any environment differences to ensure it can be reproduced as I see it.

Let me know if more information is required here so this issue can be accepted. If this is accepted, please assign it to me and I will submit my PR again.

# Run netbox 2.6.7 - postgres version is set here so we can upgrade without going through postgres upgrade process.
$ git@github.com:netbox-community/netbox-docker.git
$ cd netbox-docker
$ git checkout 0.20.0
$ cat > docker-compose.override.yml << END
version: '3.4'
services:
    postgres:
        image: postgres:11-alpine
END

$ VERSION=v2.6.7 docker-compose up

# Set up a test VM with one interface through the web interface.
Add cluster type (name "test")
Add cluster (name "test" type "test")
Add vm (name "test" cluster "test")
Add interface to vm "test" (name "test")

# Upgrade to 2.9.2 - we use tobiasge/fix-startup-2.9 as the released version does not yet support 2.9.2 (see: https://github.com/netbox-community/netbox-docker/issues/325, https://github.com/netbox-community/netbox-docker/pull/326)
$ VERSION=v2.6.7 docker-compose rm
$ git remote add tobiasge git@github.com:tobiasge/netbox-docker.git
$ git checkout tobiasge/fix-startup-2.9
# Build 2.9.2 image, and run it
$ ./build.sh v2.9.2
$ VERSION=v2.9.2 docker-compose up

### Postgres etc. etc. all start up, removed here for brevity ###

netbox_1         | Operations to perform:
netbox_1         |   Apply all migrations: admin, auth, circuits, contenttypes, dcim, extras, ipam, secrets, sessions, taggit, tenancy, users, virtualization
netbox_1         | Running migrations:
netbox_1         |   Applying auth.0012_alter_user_first_name_max_length... OK
netbox_1         |   Applying circuits.0016_3569_circuit_fields... OK
netbox_1         |   Applying circuits.0017_circuittype_description... OK
netbox_1         |   Applying circuits.0018_standardize_description... OK
netbox_1         |   Applying circuits.0019_nullbooleanfield_to_booleanfield... OK
netbox_1         |   Applying virtualization.0010_cluster_add_tenant... OK
netbox_1         |   Applying virtualization.0011_3569_virtualmachine_fields... OK
netbox_1         |   Applying virtualization.0012_vm_name_nonunique... OK
netbox_1         |   Applying virtualization.0013_deterministic_ordering... OK
netbox_1         |   Applying virtualization.0014_standardize_description... OK
netbox_1         |   Applying ipam.0028_3569_prefix_fields... OK
netbox_1         |   Applying ipam.0029_3569_ipaddress_fields... OK
netbox_1         |   Applying ipam.0030_3569_vlan_fields... OK
netbox_1         |   Applying ipam.0031_3569_service_fields... OK
netbox_1         |   Applying ipam.0032_role_description... OK
netbox_1         |   Applying ipam.0033_deterministic_ordering... OK
netbox_1         |   Applying ipam.0034_fix_ipaddress_status_dhcp... OK
netbox_1         |   Applying ipam.0035_drop_ip_family... OK
netbox_1         |   Applying ipam.0036_standardize_description... OK
netbox_1         |   Applying extras.0028_remove_topology_maps... OK
netbox_1         |   Applying extras.0029_3569_customfield_fields... OK
netbox_1         |   Applying extras.0030_3569_objectchange_fields... OK
netbox_1         |   Applying extras.0031_3569_exporttemplate_fields... OK
netbox_1         |   Applying extras.0032_3569_webhook_fields... OK
netbox_1         |   Applying extras.0033_graph_type_template_language... OK
netbox_1         |   Applying extras.0034_configcontext_tags... OK
netbox_1         |   Applying extras.0035_deterministic_ordering... OK
netbox_1         |   Applying extras.0036_contenttype_filters_to_q_objects... OK
netbox_1         |   Applying extras.0037_configcontexts_clusters... OK
netbox_1         |   Applying extras.0038_webhook_template_support... OK
netbox_1         |   Applying extras.0039_update_features_content_types... OK
netbox_1         |   Applying extras.0040_standardize_description... OK
netbox_1         |   Applying extras.0041_tag_description... OK
netbox_1         |   Applying extras.0042_customfield_manager... OK
netbox_1         |   Applying virtualization.0015_vminterface... OK
netbox_1         |   Applying ipam.0037_ipaddress_assignment... OK
netbox_1         |   Applying virtualization.0016_replicate_interfaces...
netbox_1         |     Replicating 1 VM interfaces...
postgres_1       | 2020-08-29 01:23:31.264 UTC [27] ERROR:  null value in column "mode" violates not-null constraint
postgres_1       | 2020-08-29 01:23:31.264 UTC [27] DETAIL:  Failing row contains (1, test, 9999999999999999test.................., t, null, null, null, , null, 1).
postgres_1       | 2020-08-29 01:23:31.264 UTC [27] STATEMENT:  INSERT INTO "virtualization_vminterface" ("name", "_name", "enabled", "mac_address", "mtu", "mode", "description", "untagged_vlan_id", "virtual_machine_id") VALUES ('test', '9999999999999999test..................', true, NULL, NULL, NULL, '', NULL, 1) RETURNING "virtualization_vminterface"."id"
netbox_1         | Traceback (most recent call last):
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
netbox_1         |     return self.cursor.execute(sql, params)
netbox_1         | psycopg2.errors.NotNullViolation: null value in column "mode" violates not-null constraint
netbox_1         | DETAIL:  Failing row contains (1, test, 9999999999999999test.................., t, null, null, null, , null, 1).
netbox_1         |
netbox_1         |
netbox_1         | The above exception was the direct cause of the following exception:
netbox_1         |
netbox_1         | Traceback (most recent call last):
netbox_1         |   File "./manage.py", line 10, in <module>
netbox_1         |     execute_from_command_line(sys.argv)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
netbox_1         |     utility.execute()
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute
netbox_1         |     self.fetch_command(subcommand).run_from_argv(self.argv)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 330, in run_from_argv
netbox_1         |     self.execute(*args, **cmd_options)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 371, in execute
netbox_1         |     output = self.handle(*args, **options)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 85, in wrapped
netbox_1         |     res = handle_func(*args, **kwargs)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 245, in handle
netbox_1         |     fake_initial=fake_initial,
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 117, in migrate
netbox_1         |     state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
netbox_1         |     state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
netbox_1         |     state = migration.apply(state, schema_editor)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/db/migrations/migration.py", line 124, in apply
netbox_1         |     operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/db/migrations/operations/special.py", line 190, in database_forwards
netbox_1         |     self.code(from_state.apps, schema_editor)
netbox_1         |   File "/opt/netbox/netbox/virtualization/migrations/0016_replicate_interfaces.py", line 37, in replicate_interfaces
netbox_1         |     VMInterface.objects.bulk_create(new_interfaces, batch_size=1000)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/db/models/manager.py", line 85, in manager_method
netbox_1         |     return getattr(self.get_queryset(), name)(*args, **kwargs)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/cacheops/query.py", line 373, in bulk_create
netbox_1         |     objs = self._no_monkey.bulk_create(self, objs, *args, **kwargs)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 507, in bulk_create
netbox_1         |     objs_without_pk, fields, batch_size, ignore_conflicts=ignore_conflicts,
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 1269, in _batched_insert
netbox_1         |     ignore_conflicts=ignore_conflicts,
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 1249, in _insert
netbox_1         |     return query.get_compiler(using=using).execute_sql(returning_fields)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1395, in execute_sql
netbox_1         |     cursor.execute(sql, params)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/cacheops/transaction.py", line 93, in execute
netbox_1         |     result = self._no_monkey.execute(self, sql, params)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 66, in execute
netbox_1         |     return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
netbox_1         |     return executor(sql, params, many, context)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
netbox_1         |     return self.cursor.execute(sql, params)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/db/utils.py", line 90, in __exit__
netbox_1         |     raise dj_exc_value.with_traceback(traceback) from exc_value
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
netbox_1         |     return self.cursor.execute(sql, params)
netbox_1         | django.db.utils.IntegrityError: null value in column "mode" violates not-null constraint
netbox_1         | DETAIL:  Failing row contains (1, test, 9999999999999999test.................., t, null, null, null, , null, 1).
netbox_1         |
netbox_1         | ⏳ Waiting on DB... (0s / 30s)


### Above repeats for a while ###


netbox_1         | ❌ Waited 30s or more for the DB to become ready.
netbox-docker_netbox_1 exited with code 1
@nward commented on GitHub (Aug 29, 2020): Steps to reproduce. The following is done in netbox-docker - however this issues also presents outside of docker - I'm using docker here to avoid any environment differences to ensure it can be reproduced as I see it. Let me know if more information is required here so this issue can be accepted. If this is accepted, please assign it to me and I will submit my PR again. ``` # Run netbox 2.6.7 - postgres version is set here so we can upgrade without going through postgres upgrade process. $ git@github.com:netbox-community/netbox-docker.git $ cd netbox-docker $ git checkout 0.20.0 $ cat > docker-compose.override.yml << END version: '3.4' services: postgres: image: postgres:11-alpine END $ VERSION=v2.6.7 docker-compose up # Set up a test VM with one interface through the web interface. Add cluster type (name "test") Add cluster (name "test" type "test") Add vm (name "test" cluster "test") Add interface to vm "test" (name "test") # Upgrade to 2.9.2 - we use tobiasge/fix-startup-2.9 as the released version does not yet support 2.9.2 (see: https://github.com/netbox-community/netbox-docker/issues/325, https://github.com/netbox-community/netbox-docker/pull/326) $ VERSION=v2.6.7 docker-compose rm $ git remote add tobiasge git@github.com:tobiasge/netbox-docker.git $ git checkout tobiasge/fix-startup-2.9 # Build 2.9.2 image, and run it $ ./build.sh v2.9.2 $ VERSION=v2.9.2 docker-compose up ### Postgres etc. etc. all start up, removed here for brevity ### netbox_1 | Operations to perform: netbox_1 | Apply all migrations: admin, auth, circuits, contenttypes, dcim, extras, ipam, secrets, sessions, taggit, tenancy, users, virtualization netbox_1 | Running migrations: netbox_1 | Applying auth.0012_alter_user_first_name_max_length... OK netbox_1 | Applying circuits.0016_3569_circuit_fields... OK netbox_1 | Applying circuits.0017_circuittype_description... OK netbox_1 | Applying circuits.0018_standardize_description... OK netbox_1 | Applying circuits.0019_nullbooleanfield_to_booleanfield... OK netbox_1 | Applying virtualization.0010_cluster_add_tenant... OK netbox_1 | Applying virtualization.0011_3569_virtualmachine_fields... OK netbox_1 | Applying virtualization.0012_vm_name_nonunique... OK netbox_1 | Applying virtualization.0013_deterministic_ordering... OK netbox_1 | Applying virtualization.0014_standardize_description... OK netbox_1 | Applying ipam.0028_3569_prefix_fields... OK netbox_1 | Applying ipam.0029_3569_ipaddress_fields... OK netbox_1 | Applying ipam.0030_3569_vlan_fields... OK netbox_1 | Applying ipam.0031_3569_service_fields... OK netbox_1 | Applying ipam.0032_role_description... OK netbox_1 | Applying ipam.0033_deterministic_ordering... OK netbox_1 | Applying ipam.0034_fix_ipaddress_status_dhcp... OK netbox_1 | Applying ipam.0035_drop_ip_family... OK netbox_1 | Applying ipam.0036_standardize_description... OK netbox_1 | Applying extras.0028_remove_topology_maps... OK netbox_1 | Applying extras.0029_3569_customfield_fields... OK netbox_1 | Applying extras.0030_3569_objectchange_fields... OK netbox_1 | Applying extras.0031_3569_exporttemplate_fields... OK netbox_1 | Applying extras.0032_3569_webhook_fields... OK netbox_1 | Applying extras.0033_graph_type_template_language... OK netbox_1 | Applying extras.0034_configcontext_tags... OK netbox_1 | Applying extras.0035_deterministic_ordering... OK netbox_1 | Applying extras.0036_contenttype_filters_to_q_objects... OK netbox_1 | Applying extras.0037_configcontexts_clusters... OK netbox_1 | Applying extras.0038_webhook_template_support... OK netbox_1 | Applying extras.0039_update_features_content_types... OK netbox_1 | Applying extras.0040_standardize_description... OK netbox_1 | Applying extras.0041_tag_description... OK netbox_1 | Applying extras.0042_customfield_manager... OK netbox_1 | Applying virtualization.0015_vminterface... OK netbox_1 | Applying ipam.0037_ipaddress_assignment... OK netbox_1 | Applying virtualization.0016_replicate_interfaces... netbox_1 | Replicating 1 VM interfaces... postgres_1 | 2020-08-29 01:23:31.264 UTC [27] ERROR: null value in column "mode" violates not-null constraint postgres_1 | 2020-08-29 01:23:31.264 UTC [27] DETAIL: Failing row contains (1, test, 9999999999999999test.................., t, null, null, null, , null, 1). postgres_1 | 2020-08-29 01:23:31.264 UTC [27] STATEMENT: INSERT INTO "virtualization_vminterface" ("name", "_name", "enabled", "mac_address", "mtu", "mode", "description", "untagged_vlan_id", "virtual_machine_id") VALUES ('test', '9999999999999999test..................', true, NULL, NULL, NULL, '', NULL, 1) RETURNING "virtualization_vminterface"."id" netbox_1 | Traceback (most recent call last): netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute netbox_1 | return self.cursor.execute(sql, params) netbox_1 | psycopg2.errors.NotNullViolation: null value in column "mode" violates not-null constraint netbox_1 | DETAIL: Failing row contains (1, test, 9999999999999999test.................., t, null, null, null, , null, 1). netbox_1 | netbox_1 | netbox_1 | The above exception was the direct cause of the following exception: netbox_1 | netbox_1 | Traceback (most recent call last): netbox_1 | File "./manage.py", line 10, in <module> netbox_1 | execute_from_command_line(sys.argv) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line netbox_1 | utility.execute() netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute netbox_1 | self.fetch_command(subcommand).run_from_argv(self.argv) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 330, in run_from_argv netbox_1 | self.execute(*args, **cmd_options) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 371, in execute netbox_1 | output = self.handle(*args, **options) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 85, in wrapped netbox_1 | res = handle_func(*args, **kwargs) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 245, in handle netbox_1 | fake_initial=fake_initial, netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 117, in migrate netbox_1 | state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards netbox_1 | state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/db/migrations/executor.py", line 227, in apply_migration netbox_1 | state = migration.apply(state, schema_editor) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/db/migrations/migration.py", line 124, in apply netbox_1 | operation.database_forwards(self.app_label, schema_editor, old_state, project_state) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/db/migrations/operations/special.py", line 190, in database_forwards netbox_1 | self.code(from_state.apps, schema_editor) netbox_1 | File "/opt/netbox/netbox/virtualization/migrations/0016_replicate_interfaces.py", line 37, in replicate_interfaces netbox_1 | VMInterface.objects.bulk_create(new_interfaces, batch_size=1000) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/db/models/manager.py", line 85, in manager_method netbox_1 | return getattr(self.get_queryset(), name)(*args, **kwargs) netbox_1 | File "/usr/local/lib/python3.7/site-packages/cacheops/query.py", line 373, in bulk_create netbox_1 | objs = self._no_monkey.bulk_create(self, objs, *args, **kwargs) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 507, in bulk_create netbox_1 | objs_without_pk, fields, batch_size, ignore_conflicts=ignore_conflicts, netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 1269, in _batched_insert netbox_1 | ignore_conflicts=ignore_conflicts, netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 1249, in _insert netbox_1 | return query.get_compiler(using=using).execute_sql(returning_fields) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1395, in execute_sql netbox_1 | cursor.execute(sql, params) netbox_1 | File "/usr/local/lib/python3.7/site-packages/cacheops/transaction.py", line 93, in execute netbox_1 | result = self._no_monkey.execute(self, sql, params) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 66, in execute netbox_1 | return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers netbox_1 | return executor(sql, params, many, context) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute netbox_1 | return self.cursor.execute(sql, params) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/db/utils.py", line 90, in __exit__ netbox_1 | raise dj_exc_value.with_traceback(traceback) from exc_value netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute netbox_1 | return self.cursor.execute(sql, params) netbox_1 | django.db.utils.IntegrityError: null value in column "mode" violates not-null constraint netbox_1 | DETAIL: Failing row contains (1, test, 9999999999999999test.................., t, null, null, null, , null, 1). netbox_1 | netbox_1 | ⏳ Waiting on DB... (0s / 30s) ### Above repeats for a while ### netbox_1 | ❌ Waited 30s or more for the DB to become ready. netbox-docker_netbox_1 exited with code 1 ```
Author
Owner

@jeremystretch commented on GitHub (Sep 9, 2020):

I've updated the virtualization.0016_replicate_interfaces schema migration to require that dcim.0082_3569_interface_fields runs first. I'm pretty confident this will fix the issue, but please test and let me know.

@jeremystretch commented on GitHub (Sep 9, 2020): I've updated the `virtualization.0016_replicate_interfaces` schema migration to require that `dcim.0082_3569_interface_fields` runs first. I'm pretty confident this will fix the issue, but please test and let me know.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4025