netbox-community / netbox-docker

🐳 Docker Image of NetBox
https://github.com/netbox-community/netbox-docker/wiki
Apache License 2.0
1.85k stars 856 forks source link

Error upgrading from 4.0.11 (2.9.1) to 4.1.0 (3.0.1) #1314

Closed avbor closed 1 month ago

avbor commented 1 month ago

Current Behavior

Errors during update from 4.0.11 (2.9.1) to 4.1.0 (3.0.1):

Running migrations:
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/psycopg/cursor.py", line 97, in execute
    raise ex.with_traceback(None)
psycopg.errors.UndefinedTable: relation "extras_objectchange" does not exist
LINE 1: ...ct_type_id", "extras_objectchange"."user_id" FROM "extras_ob...
                                                             ^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/netbox/netbox/./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/base.py", line 459, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/base.py", line 107, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/commands/migrate.py", line 356, in handle
    post_migrate_state = executor.migrate(
                         ^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/migrations/executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
            ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
    state = migration.apply(state, schema_editor)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/migrations/migration.py", line 132, in apply
    operation.database_forwards(
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/migrations/operations/special.py", line 193, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/opt/netbox/netbox/extras/migrations/0117_move_objectchange.py", line 8, in update_content_types
    ContentType.objects.filter(app_label='core', model='objectchange').delete()
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/query.py", line 1187, in delete
    collector.collect(del_query)
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/deletion.py", line 348, in collect
    if getattr(on_delete, "lazy_sub_objs", False) or sub_objs:
                                                     ^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/query.py", line 414, in __bool__
    self._fetch_all()
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/query.py", line 1928, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/query.py", line 91, in __iter__
    results = compiler.execute_sql(
              ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 1562, in execute_sql
    cursor.execute(sql, params)
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 79, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 100, in _execute
    with self.db.wrap_database_errors:
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/psycopg/cursor.py", line 97, in execute
    raise ex.with_traceback(None)
django.db.utils.ProgrammingError: relation "extras_objectchange" does not exist
LINE 1: ...ct_type_id", "extras_objectchange"."user_id" FROM "extras_ob...

Logs from postgresql:

2024-09-06 14:38:46.022 UTC [1] LOG:  starting PostgreSQL 16.4 on x86_64-pc-linux-musl, compiled by gcc (Alpine 13.2.1_git20240309) 13.2.1 20240309, 64-bit
2024-09-06 14:38:46.023 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2024-09-06 14:38:46.023 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2024-09-06 14:38:46.030 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-09-06 14:38:46.040 UTC [29] LOG:  database system was shut down at 2024-09-06 14:38:44 UTC
2024-09-06 14:38:46.058 UTC [1] LOG:  database system is ready to accept connections
2024-09-06 14:38:55.130 UTC [40] LOG:  statement: SELECT "django_content_type"."id", "django_content_type"."app_label", "django_content_type"."model" FROM "django_content_type" WHERE (("django_content_type"."app_label" = 'auth' AND "django_content_type"."model" IN ('group', 'permission')) OR ("django_content_type"."app_label" = 'contenttypes' AND "django_content_type"."model" IN ('contenttype')) OR ("django_content_type"."app_label" = 'sessions' AND "django_content_type"."model" IN ('session')) OR ("django_content_type"."app_label" = 'social_django' AND "django_content_type"."model" IN ('usersocialauth', 'partial', 'nonce', 'code', 'association')) OR ("django_content_type"."app_label" = 'taggit' AND "django_content_type"."model" IN ('taggeditem', 'tag')) OR ("django_content_type"."app_label" = 'core' AND "django_content_type"."model" IN ('managedfile', 'job', 'datasource', 'datafile', 'objectchange', 'autosyncrecord', 'configrevision')) OR ("django_content_type"."app_label" = 'users' AND "django_content_type"."model" IN ('group', 'token', 'objectpermission', 'userconfig', 'user')) OR ("django_content_type"."app_label" = 'circuits' AND "django_content_type"."model" IN ('provider', 'circuittermination', 'providernetwork', 'circuitgroup', 'circuit', 'provideraccount', 'circuittype', 'circuitgroupassignment')) OR ("django_content_type"."app_label" = 'dcim' AND "django_content_type"."model" IN ('frontporttemplate', 'powerport', 'powerporttemplate', 'platform', 'consoleserverport', 'interface', 'manufacturer', 'poweroutlettemplate', 'devicerole', 'consoleport', 'consoleserverporttemplate', 'rackreservation', 'site', 'racktype', 'frontport', 'rearport', 'module', 'moduletype', 'virtualdevicecontext', 'region', 'modulebay', 'inventoryitemtemplate', 'devicetype', 'devicebay', 'virtualchassis', 'devicebaytemplate', 'poweroutlet', 'inventoryitemrole', 'interfacetemplate', 'cablepath', 'cable', 'device', 'rearporttemplate', 'modulebaytemplate', 'powerpanel', 'consoleporttemplate', 'rack', 'rackrole', 'location', 'powerfeed', 'inventoryitem', 'cabletermination', 'sitegroup')) OR ("django_content_type"."app_label" = 'ipam' AND "django_content_type"."model" IN ('servicetemplate', 'iprange', 'vlan', 'fhrpgroupassignment', 'asnrange', 'role', 'ipaddress', 'service', 'vlangroup', 'fhrpgroup', 'routetarget', 'aggregate', 'rir', 'prefix', 'vrf', 'asn')) OR ("django_content_type"."app_label" = 'extras' AND "django_content_type"."model" IN ('bookmark', 'imageattachment', 'cachedvalue', 'notification', 'taggeditem', 'journalentry', 'eventrule', 'stagedchange', 'configtemplate', 'webhook', 'customfield', 'subscription', 'tag', 'savedfilter', 'configcontext', 'customfieldchoiceset', 'branch', 'customlink', 'notificationgroup', 'script', 'dashboard', 'exporttemplate')) OR ("django_content_type"."app_label" = 'tenancy' AND "django_content_type"."model" IN ('contact', 'contactassignment', 'tenant', 'tenantgroup', 'contactgroup', 'contactrole')) OR ("django_content_type"."app_label" = 'virtualization' AND "django_content_type"."model" IN ('clustergroup', 'virtualdisk', 'vminterface', 'cluster', 'clustertype', 'virtualmachine')) OR ("django_content_type"."app_label" = 'vpn' AND "django_content_type"."model" IN ('tunnel', 'ikeproposal', 'ipsecproposal', 'l2vpntermination', 'tunnelgroup', 'tunneltermination', 'ipsecpolicy', 'ipsecprofile', 'l2vpn', 'ikepolicy')) OR ("django_content_type"."app_label" = 'wireless' AND "django_content_type"."model" IN ('wirelesslangroup', 'wirelesslan', 'wirelesslink')) OR ("django_content_type"."app_label" = 'django_rq' AND "django_content_type"."model" IN ('queue')) OR ("django_content_type"."app_label" = 'netbox_dns' AND "django_content_type"."model" IN ('zone', 'recordtemplate', 'registrar', 'view', 'record', 'zonetemplate', 'registrationcontact', 'nameserver')))
2024-09-06 14:38:56.719 UTC [40] LOG:  statement:
                    SELECT
                        c.relname,
                        CASE
                            WHEN c.relispartition THEN 'p'
                            WHEN c.relkind IN ('m', 'v') THEN 'v'
                            ELSE 't'
                        END,
                        obj_description(c.oid, 'pg_class')
                    FROM pg_catalog.pg_class c
                    LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
                    WHERE c.relkind IN ('f', 'm', 'p', 'r', 'v')
                        AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
                        AND pg_catalog.pg_table_is_visible(c.oid)

2024-09-06 14:38:56.762 UTC [40] LOG:  statement: SELECT "django_migrations"."id", "django_migrations"."app", "django_migrations"."name", "django_migrations"."applied" FROM "django_migrations"
2024-09-06 14:38:56.781 UTC [40] LOG:  statement:
                    SELECT
                        c.relname,
                        CASE
                            WHEN c.relispartition THEN 'p'
                            WHEN c.relkind IN ('m', 'v') THEN 'v'
                            ELSE 't'
                        END,
                        obj_description(c.oid, 'pg_class')
                    FROM pg_catalog.pg_class c
                    LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
                    WHERE c.relkind IN ('f', 'm', 'p', 'r', 'v')
                        AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
                        AND pg_catalog.pg_table_is_visible(c.oid)

2024-09-06 14:38:56.797 UTC [40] LOG:  statement: SELECT "django_migrations"."id", "django_migrations"."app", "django_migrations"."name", "django_migrations"."applied" FROM "django_migrations"
2024-09-06 14:39:08.064 UTC [48] LOG:  statement: SELECT "django_content_type"."id", "django_content_type"."app_label", "django_content_type"."model" FROM "django_content_type" WHERE (("django_content_type"."app_label" = 'auth' AND "django_content_type"."model" IN ('permission', 'group')) OR ("django_content_type"."app_label" = 'contenttypes' AND "django_content_type"."model" IN ('contenttype')) OR ("django_content_type"."app_label" = 'sessions' AND "django_content_type"."model" IN ('session')) OR ("django_content_type"."app_label" = 'social_django' AND "django_content_type"."model" IN ('code', 'nonce', 'usersocialauth', 'association', 'partial')) OR ("django_content_type"."app_label" = 'taggit' AND "django_content_type"."model" IN ('taggeditem', 'tag')) OR ("django_content_type"."app_label" = 'core' AND "django_content_type"."model" IN ('datasource', 'job', 'autosyncrecord', 'managedfile', 'objectchange', 'configrevision', 'datafile')) OR ("django_content_type"."app_label" = 'users' AND "django_content_type"."model" IN ('user', 'token', 'group', 'userconfig', 'objectpermission')) OR ("django_content_type"."app_label" = 'circuits' AND "django_content_type"."model" IN ('circuittype', 'provideraccount', 'circuit', 'circuitgroupassignment', 'circuittermination', 'providernetwork', 'provider', 'circuitgroup')) OR ("django_content_type"."app_label" = 'dcim' AND "django_content_type"."model" IN ('cablepath', 'consoleporttemplate', 'virtualchassis', 'powerport', 'interface', 'cable', 'rackrole', 'consoleserverport', 'inventoryitemrole', 'moduletype', 'rack', 'region', 'modulebaytemplate', 'devicerole', 'powerporttemplate', 'poweroutlettemplate', 'poweroutlet', 'devicebay', 'manufacturer', 'cabletermination', 'module', 'modulebay', 'site', 'frontporttemplate', 'powerfeed', 'platform', 'rearporttemplate', 'rearport', 'interfacetemplate', 'consoleport', 'virtualdevicecontext', 'device', 'devicetype', 'powerpanel', 'frontport', 'location', 'devicebaytemplate', 'inventoryitemtemplate', 'sitegroup', 'inventoryitem', 'racktype', 'rackreservation', 'consoleserverporttemplate')) OR ("django_content_type"."app_label" = 'ipam' AND "django_content_type"."model" IN ('vrf', 'routetarget', 'role', 'rir', 'servicetemplate', 'asn', 'aggregate', 'fhrpgroup', 'prefix', 'iprange', 'vlangroup', 'asnrange', 'service', 'ipaddress', 'fhrpgroupassignment', 'vlan')) OR ("django_content_type"."app_label" = 'extras' AND "django_content_type"."model" IN ('customfield', 'bookmark', 'configcontext', 'webhook', 'tag', 'customfieldchoiceset', 'dashboard', 'customlink', 'journalentry', 'stagedchange', 'taggeditem', 'branch', 'imageattachment', 'notification', 'script', 'exporttemplate', 'configtemplate', 'cachedvalue', 'eventrule', 'subscription', 'savedfilter', 'notificationgroup')) OR ("django_content_type"."app_label" = 'tenancy' AND "django_content_type"."model" IN ('contactassignment', 'tenant', 'tenantgroup', 'contact', 'contactgroup', 'contactrole')) OR ("django_content_type"."app_label" = 'virtualization' AND "django_content_type"."model" IN ('cluster', 'vminterface', 'clustertype', 'virtualdisk', 'virtualmachine', 'clustergroup')) OR ("django_content_type"."app_label" = 'vpn' AND "django_content_type"."model" IN ('ipsecprofile', 'l2vpntermination', 'tunnel', 'ipsecpolicy', 'tunneltermination', 'ikeproposal', 'tunnelgroup', 'ipsecproposal', 'ikepolicy', 'l2vpn')) OR ("django_content_type"."app_label" = 'wireless' AND "django_content_type"."model" IN ('wirelesslangroup', 'wirelesslan', 'wirelesslink')) OR ("django_content_type"."app_label" = 'django_rq' AND "django_content_type"."model" IN ('queue')) OR ("django_content_type"."app_label" = 'netbox_dns' AND "django_content_type"."model" IN ('registrar', 'zone', 'record', 'recordtemplate', 'nameserver', 'zonetemplate', 'registrationcontact', 'view')))
2024-09-06 14:39:09.654 UTC [48] LOG:  statement:
                    SELECT
                        c.relname,
                        CASE
                            WHEN c.relispartition THEN 'p'
                            WHEN c.relkind IN ('m', 'v') THEN 'v'
                            ELSE 't'
                        END,
                        obj_description(c.oid, 'pg_class')
                    FROM pg_catalog.pg_class c
                    LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
                    WHERE c.relkind IN ('f', 'm', 'p', 'r', 'v')
                        AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
                        AND pg_catalog.pg_table_is_visible(c.oid)

2024-09-06 14:39:09.698 UTC [48] LOG:  statement: SELECT "django_migrations"."id", "django_migrations"."app", "django_migrations"."name", "django_migrations"."applied" FROM "django_migrations"
2024-09-06 14:39:09.717 UTC [48] LOG:  statement:
                    SELECT
                        c.relname,
                        CASE
                            WHEN c.relispartition THEN 'p'
                            WHEN c.relkind IN ('m', 'v') THEN 'v'
                            ELSE 't'
                        END,
                        obj_description(c.oid, 'pg_class')
                    FROM pg_catalog.pg_class c
                    LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
                    WHERE c.relkind IN ('f', 'm', 'p', 'r', 'v')
                        AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
                        AND pg_catalog.pg_table_is_visible(c.oid)

2024-09-06 14:39:09.732 UTC [48] LOG:  statement: SELECT "django_migrations"."id", "django_migrations"."app", "django_migrations"."name", "django_migrations"."applied" FROM "django_migrations"
2024-09-06 14:39:20.724 UTC [56] LOG:  statement: SELECT "django_content_type"."id", "django_content_type"."app_label", "django_content_type"."model" FROM "django_content_type" WHERE (("django_content_type"."app_label" = 'auth' AND "django_content_type"."model" IN ('group', 'permission')) OR ("django_content_type"."app_label" = 'contenttypes' AND "django_content_type"."model" IN ('contenttype')) OR ("django_content_type"."app_label" = 'sessions' AND "django_content_type"."model" IN ('session')) OR ("django_content_type"."app_label" = 'social_django' AND "django_content_type"."model" IN ('partial', 'nonce', 'code', 'association', 'usersocialauth')) OR ("django_content_type"."app_label" = 'taggit' AND "django_content_type"."model" IN ('tag', 'taggeditem')) OR ("django_content_type"."app_label" = 'core' AND "django_content_type"."model" IN ('managedfile', 'datafile', 'job', 'configrevision', 'objectchange', 'autosyncrecord', 'datasource')) OR ("django_content_type"."app_label" = 'users' AND "django_content_type"."model" IN ('user', 'group', 'userconfig', 'objectpermission', 'token')) OR ("django_content_type"."app_label" = 'circuits' AND "django_content_type"."model" IN ('circuit', 'provideraccount', 'circuitgroup', 'circuitgroupassignment', 'circuittype', 'providernetwork', 'provider', 'circuittermination')) OR ("django_content_type"."app_label" = 'dcim' AND "django_content_type"."model" IN ('powerpanel', 'devicerole', 'manufacturer', 'location', 'cable', 'devicetype', 'powerport', 'platform', 'racktype', 'consoleserverporttemplate', 'rackreservation', 'poweroutlettemplate', 'device', 'cabletermination', 'region', 'powerporttemplate', 'inventoryitemrole', 'moduletype', 'site', 'devicebay', 'module', 'interface', 'frontporttemplate', 'virtualdevicecontext', 'rackrole', 'virtualchassis', 'inventoryitem', 'modulebaytemplate', 'rearporttemplate', 'interfacetemplate', 'cablepath', 'sitegroup', 'powerfeed', 'consoleporttemplate', 'frontport', 'consoleserverport', 'devicebaytemplate', 'inventoryitemtemplate', 'poweroutlet', 'rearport', 'consoleport', 'modulebay', 'rack')) OR ("django_content_type"."app_label" = 'ipam' AND "django_content_type"."model" IN ('asn', 'vlangroup', 'iprange', 'ipaddress', 'vrf', 'routetarget', 'rir', 'prefix', 'servicetemplate', 'aggregate', 'asnrange', 'role', 'service', 'vlan', 'fhrpgroup', 'fhrpgroupassignment')) OR ("django_content_type"."app_label" = 'extras' AND "django_content_type"."model" IN ('stagedchange', 'imageattachment', 'exporttemplate', 'notificationgroup', 'tag', 'eventrule', 'webhook', 'journalentry', 'customfield', 'customlink', 'configcontext', 'customfieldchoiceset', 'savedfilter', 'bookmark', 'subscription', 'dashboard', 'cachedvalue', 'script', 'notification', 'taggeditem', 'configtemplate', 'branch')) OR ("django_content_type"."app_label" = 'tenancy' AND "django_content_type"."model" IN ('contact', 'contactrole', 'tenant', 'tenantgroup', 'contactgroup', 'contactassignment')) OR ("django_content_type"."app_label" = 'virtualization' AND "django_content_type"."model" IN ('cluster', 'vminterface', 'virtualmachine', 'virtualdisk', 'clustergroup', 'clustertype')) OR ("django_content_type"."app_label" = 'vpn' AND "django_content_type"."model" IN ('l2vpn', 'ipsecproposal', 'ikepolicy', 'tunnel', 'tunneltermination', 'ipsecpolicy', 'tunnelgroup', 'ipsecprofile', 'l2vpntermination', 'ikeproposal')) OR ("django_content_type"."app_label" = 'wireless' AND "django_content_type"."model" IN ('wirelesslangroup', 'wirelesslink', 'wirelesslan')) OR ("django_content_type"."app_label" = 'django_rq' AND "django_content_type"."model" IN ('queue')) OR ("django_content_type"."app_label" = 'netbox_dns' AND "django_content_type"."model" IN ('nameserver', 'zonetemplate', 'view', 'record', 'registrar', 'recordtemplate', 'registrationcontact', 'zone')))
2024-09-06 14:39:22.333 UTC [56] LOG:  statement:
                    SELECT
                        c.relname,
                        CASE
                            WHEN c.relispartition THEN 'p'
                            WHEN c.relkind IN ('m', 'v') THEN 'v'
                            ELSE 't'
                        END,
                        obj_description(c.oid, 'pg_class')
                    FROM pg_catalog.pg_class c
                    LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
                    WHERE c.relkind IN ('f', 'm', 'p', 'r', 'v')
                        AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
                        AND pg_catalog.pg_table_is_visible(c.oid)

2024-09-06 14:39:22.375 UTC [56] LOG:  statement: SELECT "django_migrations"."id", "django_migrations"."app", "django_migrations"."name", "django_migrations"."applied" FROM "django_migrations"
2024-09-06 14:39:22.395 UTC [56] LOG:  statement:
                    SELECT
                        c.relname,
                        CASE
                            WHEN c.relispartition THEN 'p'
                            WHEN c.relkind IN ('m', 'v') THEN 'v'
                            ELSE 't'
                        END,
                        obj_description(c.oid, 'pg_class')
                    FROM pg_catalog.pg_class c
                    LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
                    WHERE c.relkind IN ('f', 'm', 'p', 'r', 'v')
                        AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
                        AND pg_catalog.pg_table_is_visible(c.oid)

2024-09-06 14:39:22.412 UTC [56] LOG:  statement: SELECT "django_migrations"."id", "django_migrations"."app", "django_migrations"."name", "django_migrations"."applied" FROM "django_migrations"
2024-09-06 14:39:22.887 UTC [56] LOG:  statement:
                    SELECT
                        c.relname,
                        CASE
                            WHEN c.relispartition THEN 'p'
                            WHEN c.relkind IN ('m', 'v') THEN 'v'
                            ELSE 't'
                        END,
                        obj_description(c.oid, 'pg_class')
                    FROM pg_catalog.pg_class c
                    LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
                    WHERE c.relkind IN ('f', 'm', 'p', 'r', 'v')
                        AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
                        AND pg_catalog.pg_table_is_visible(c.oid)

2024-09-06 14:39:22.981 UTC [56] LOG:  statement: BEGIN
2024-09-06 14:39:22.981 UTC [56] LOG:  statement: ALTER TABLE "extras_objectchange" RENAME TO "core_objectchange"
2024-09-06 14:39:22.989 UTC [56] LOG:  statement: ALTER TABLE extras_objectchange_id_seq  RENAME TO core_objectchange_id_seq
2024-09-06 14:39:22.992 UTC [56] LOG:  statement: ALTER INDEX extras_objectchange_pkey  RENAME TO core_objectchange_pkey
2024-09-06 14:39:23.000 UTC [56] LOG:  statement: ALTER INDEX extras_obje_changed_927fe5_idx  RENAME TO core_objectchange_changed_object_type_id_cha_79a9ed1e
2024-09-06 14:39:23.004 UTC [56] LOG:  statement: ALTER INDEX extras_obje_related_bfcdef_idx  RENAME TO core_objectchange_related_object_type_id_rel_a71d604a
2024-09-06 14:39:23.009 UTC [56] LOG:  statement: ALTER INDEX extras_objectchange_changed_object_type_id_b755bb60  RENAME TO core_objectchange_changed_object_type_id_2070ade6
2024-09-06 14:39:23.012 UTC [56] LOG:  statement: ALTER INDEX extras_objectchange_related_object_type_id_fe6e521f  RENAME TO core_objectchange_related_object_type_id_b80958af
2024-09-06 14:39:23.016 UTC [56] LOG:  statement: ALTER INDEX extras_objectchange_request_id_4ae21e90  RENAME TO core_objectchange_request_id_d9d160ac
2024-09-06 14:39:23.019 UTC [56] LOG:  statement: ALTER INDEX extras_objectchange_time_224380ea  RENAME TO core_objectchange_time_800f60a5
2024-09-06 14:39:23.022 UTC [56] LOG:  statement: ALTER INDEX extras_objectchange_user_id_7fdf8186  RENAME TO core_objectchange_user_id_2b2142be
2024-09-06 14:39:23.025 UTC [56] LOG:  statement: ALTER TABLE core_objectchange RENAME CONSTRAINT extras_objectchange_changed_object_id_check TO core_objectchange_changed_object_id_check
2024-09-06 14:39:23.029 UTC [56] LOG:  statement: ALTER TABLE core_objectchange RENAME CONSTRAINT extras_objectchange_related_object_id_check TO core_objectchange_related_object_id_check
2024-09-06 14:39:23.032 UTC [56] LOG:  statement: ALTER TABLE core_objectchange RENAME CONSTRAINT extras_objectchange_changed_object_type__b755bb60_fk_django_co TO core_objectchange_changed_object_type_id_2070ade6
2024-09-06 14:39:23.036 UTC [56] LOG:  statement: ALTER TABLE core_objectchange RENAME CONSTRAINT extras_objectchange_related_object_type__fe6e521f_fk_django_co TO core_objectchange_related_object_type_id_b80958af
2024-09-06 14:39:23.039 UTC [56] LOG:  statement: ALTER TABLE core_objectchange RENAME CONSTRAINT extras_objectchange_user_id_7fdf8186_fk_auth_user_id TO core_objectchange_user_id_2b2142be
2024-09-06 14:39:23.043 UTC [56] LOG:  statement: SELECT "django_content_type"."id", "django_content_type"."app_label", "django_content_type"."model" FROM "django_content_type" WHERE ("django_content_type"."app_label" = 'core' AND "django_content_type"."model" = 'objectchange')
2024-09-06 14:39:23.046 UTC [56] LOG:  statement: SELECT "auth_permission"."id", "auth_permission"."name", "auth_permission"."content_type_id", "auth_permission"."codename" FROM "auth_permission" INNER JOIN "django_content_type" ON ("auth_permission"."content_type_id" = "django_content_type"."id") WHERE "auth_permission"."content_type_id" IN (166) ORDER BY "django_content_type"."app_label" ASC, "django_content_type"."model" ASC, "auth_permission"."codename" ASC
2024-09-06 14:39:23.054 UTC [56] LOG:  statement: SELECT "core_autosyncrecord"."id", "core_autosyncrecord"."object_id", "core_autosyncrecord"."datafile_id", "core_autosyncrecord"."object_type_id" FROM "core_autosyncrecord" WHERE "core_autosyncrecord"."object_type_id" IN (166)
2024-09-06 14:39:23.061 UTC [56] LOG:  statement: SELECT "core_job"."id", "core_job"."object_id", "core_job"."name", "core_job"."created", "core_job"."scheduled", "core_job"."interval", "core_job"."started", "core_job"."completed", "core_job"."status", "core_job"."data", "core_job"."job_id", "core_job"."object_type_id", "core_job"."user_id", "core_job"."error" FROM "core_job" WHERE "core_job"."object_type_id" IN (166) ORDER BY "core_job"."created" DESC
2024-09-06 14:39:23.070 UTC [56] LOG:  statement: SELECT "core_objectchange"."id", "core_objectchange"."time", "core_objectchange"."user_name", "core_objectchange"."request_id", "core_objectchange"."action", "core_objectchange"."changed_object_id", "core_objectchange"."related_object_id", "core_objectchange"."object_repr", "core_objectchange"."prechange_data", "core_objectchange"."postchange_data", "core_objectchange"."changed_object_type_id", "core_objectchange"."related_object_type_id", "core_objectchange"."user_id" FROM "core_objectchange" WHERE "core_objectchange"."changed_object_type_id" IN (166) ORDER BY "core_objectchange"."time" DESC
2024-09-06 14:39:23.077 UTC [56] LOG:  statement: SELECT "core_objectchange"."id", "core_objectchange"."time", "core_objectchange"."user_name", "core_objectchange"."request_id", "core_objectchange"."action", "core_objectchange"."changed_object_id", "core_objectchange"."related_object_id", "core_objectchange"."object_repr", "core_objectchange"."prechange_data", "core_objectchange"."postchange_data", "core_objectchange"."changed_object_type_id", "core_objectchange"."related_object_type_id", "core_objectchange"."user_id" FROM "core_objectchange" WHERE "core_objectchange"."related_object_type_id" IN (166) ORDER BY "core_objectchange"."time" DESC
2024-09-06 14:39:23.082 UTC [56] LOG:  statement: SELECT "dcim_inventoryitem"."id", "dcim_inventoryitem"."created", "dcim_inventoryitem"."last_updated", "dcim_inventoryitem"."custom_field_data", "dcim_inventoryitem"."name", "dcim_inventoryitem"."_name", "dcim_inventoryitem"."label", "dcim_inventoryitem"."description", "dcim_inventoryitem"."part_id", "dcim_inventoryitem"."serial", "dcim_inventoryitem"."asset_tag", "dcim_inventoryitem"."discovered", "dcim_inventoryitem"."lft", "dcim_inventoryitem"."rght", "dcim_inventoryitem"."tree_id", "dcim_inventoryitem"."level", "dcim_inventoryitem"."device_id", "dcim_inventoryitem"."manufacturer_id", "dcim_inventoryitem"."parent_id", "dcim_inventoryitem"."role_id", "dcim_inventoryitem"."component_id", "dcim_inventoryitem"."component_type_id" FROM "dcim_inventoryitem" WHERE "dcim_inventoryitem"."component_type_id" IN (166) ORDER BY "dcim_inventoryitem"."device_id" ASC, "dcim_inventoryitem"."parent_id" ASC, "dcim_inventoryitem"."_name" ASC
2024-09-06 14:39:23.098 UTC [56] LOG:  statement: SELECT "dcim_inventoryitemtemplate"."id", "dcim_inventoryitemtemplate"."created", "dcim_inventoryitemtemplate"."last_updated", "dcim_inventoryitemtemplate"."name", "dcim_inventoryitemtemplate"."_name", "dcim_inventoryitemtemplate"."label", "dcim_inventoryitemtemplate"."description", "dcim_inventoryitemtemplate"."component_id", "dcim_inventoryitemtemplate"."part_id", "dcim_inventoryitemtemplate"."lft", "dcim_inventoryitemtemplate"."rght", "dcim_inventoryitemtemplate"."tree_id", "dcim_inventoryitemtemplate"."level", "dcim_inventoryitemtemplate"."component_type_id", "dcim_inventoryitemtemplate"."device_type_id", "dcim_inventoryitemtemplate"."manufacturer_id", "dcim_inventoryitemtemplate"."parent_id", "dcim_inventoryitemtemplate"."role_id" FROM "dcim_inventoryitemtemplate" WHERE "dcim_inventoryitemtemplate"."component_type_id" IN (166) ORDER BY "dcim_inventoryitemtemplate"."device_type_id" ASC, "dcim_inventoryitemtemplate"."parent_id" ASC, "dcim_inventoryitemtemplate"."_name" ASC
2024-09-06 14:39:23.108 UTC [56] LOG:  statement: SELECT "dcim_cabletermination"."id", "dcim_cabletermination"."cable_end", "dcim_cabletermination"."termination_id", "dcim_cabletermination"."cable_id", "dcim_cabletermination"."termination_type_id", "dcim_cabletermination"."_device_id", "dcim_cabletermination"."_rack_id", "dcim_cabletermination"."_location_id", "dcim_cabletermination"."_site_id", "dcim_cabletermination"."created", "dcim_cabletermination"."last_updated" FROM "dcim_cabletermination" INNER JOIN "dcim_cable" ON ("dcim_cabletermination"."cable_id" = "dcim_cable"."id") WHERE "dcim_cabletermination"."termination_type_id" IN (166) ORDER BY "dcim_cable"."id" ASC, "dcim_cabletermination"."cable_end" ASC, "dcim_cabletermination"."id" ASC
2024-09-06 14:39:23.125 UTC [56] LOG:  statement: SELECT "extras_tag_object_types"."id", "extras_tag_object_types"."tag_id", "extras_tag_object_types"."objecttype_id" FROM "extras_tag_object_types" WHERE "extras_tag_object_types"."objecttype_id" IN (166)
2024-09-06 14:39:23.132 UTC [56] LOG:  statement: SELECT "extras_taggeditem"."id", "extras_taggeditem"."object_id", "extras_taggeditem"."content_type_id", "extras_taggeditem"."tag_id" FROM "extras_taggeditem" WHERE "extras_taggeditem"."content_type_id" IN (166)
2024-09-06 14:39:23.140 UTC [56] LOG:  statement: SELECT "extras_objectchange"."id", "extras_objectchange"."time", "extras_objectchange"."user_name", "extras_objectchange"."request_id", "extras_objectchange"."action", "extras_objectchange"."changed_object_id", "extras_objectchange"."related_object_id", "extras_objectchange"."object_repr", "extras_objectchange"."prechange_data", "extras_objectchange"."postchange_data", "extras_objectchange"."changed_object_type_id", "extras_objectchange"."related_object_type_id", "extras_objectchange"."user_id" FROM "extras_objectchange" WHERE "extras_objectchange"."changed_object_type_id" IN (166) ORDER BY "extras_objectchange"."time" DESC
2024-09-06 14:39:23.140 UTC [56] ERROR:  relation "extras_objectchange" does not exist at character 506
2024-09-06 14:39:23.140 UTC [56] STATEMENT:  SELECT "extras_objectchange"."id", "extras_objectchange"."time", "extras_objectchange"."user_name", "extras_objectchange"."request_id", "extras_objectchange"."action", "extras_objectchange"."changed_object_id", "extras_objectchange"."related_object_id", "extras_objectchange"."object_repr", "extras_objectchange"."prechange_data", "extras_objectchange"."postchange_data", "extras_objectchange"."changed_object_type_id", "extras_objectchange"."related_object_type_id", "extras_objectchange"."user_id" FROM "extras_objectchange" WHERE "extras_objectchange"."changed_object_type_id" IN (166) ORDER BY "extras_objectchange"."time" DESC
2024-09-06 14:39:23.143 UTC [56] LOG:  statement: ROLLBACK

Expected Behavior

No errors during upgrade

Docker Compose Version

Docker Compose version v2.29.2

Docker Version

Client: Docker Engine - Community
 Version:           27.2.0
 API version:       1.47
 Go version:        go1.21.13
 Git commit:        3ab4256
 Built:             Tue Aug 27 14:15:13 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          27.2.0
  API version:      1.47 (minimum version 1.24)
  Go version:       go1.21.13
  Git commit:       3ab5c7d
  Built:            Tue Aug 27 14:15:13 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.21
  GitCommit:        472731909fa34bd7bc9c087e4c27943f9835f111
 runc:
  Version:          1.1.13
  GitCommit:        v1.1.13-0-g58aa920
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

The git Revision

5add31ee7a55da8872efaa95278037a0e34020d5

The git Status

On branch release
Your branch is up to date with 'origin/release'.

nothing to commit, working tree clean

Startup Command

docker compose up -d

NetBox Logs

Applying extras.0117_move_objectchange...⚙️ Applying database migrations
🧬 loaded config '/etc/netbox/config/configuration.py'
🧬 loaded config '/etc/netbox/config/custom_config.py'
🧬 loaded config '/etc/netbox/config/extra.py'
🧬 loaded config '/etc/netbox/config/logging.py'
🧬 loaded config '/etc/netbox/config/plugins.py'
Operations to perform:
  Apply all migrations: account, auth, circuits, contenttypes, core, dcim, django_rq, extras, ipam, netbox_dns, sessions, social_django, taggit, tenancy, users, virtualization, vpn, wireless
Running migrations:
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/psycopg/cursor.py", line 97, in execute
    raise ex.with_traceback(None)
psycopg.errors.UndefinedTable: relation "extras_objectchange" does not exist
LINE 1: ...ct_type_id", "extras_objectchange"."user_id" FROM "extras_ob...
                                                             ^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/netbox/netbox/./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/base.py", line 459, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/base.py", line 107, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/commands/migrate.py", line 356, in handle
    post_migrate_state = executor.migrate(
                         ^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/migrations/executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
            ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
    state = migration.apply(state, schema_editor)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/migrations/migration.py", line 132, in apply
    operation.database_forwards(
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/migrations/operations/special.py", line 193, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/opt/netbox/netbox/extras/migrations/0117_move_objectchange.py", line 8, in update_content_types
    ContentType.objects.filter(app_label='core', model='objectchange').delete()
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/query.py", line 1187, in delete
    collector.collect(del_query)
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/deletion.py", line 348, in collect
    if getattr(on_delete, "lazy_sub_objs", False) or sub_objs:
                                                     ^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/query.py", line 414, in __bool__
    self._fetch_all()
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/query.py", line 1928, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/query.py", line 91, in __iter__
    results = compiler.execute_sql(
              ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 1562, in execute_sql
    cursor.execute(sql, params)
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 79, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 100, in _execute
    with self.db.wrap_database_errors:
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 105, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib/python3.12/site-packages/psycopg/cursor.py", line 97, in execute
    raise ex.with_traceback(None)
django.db.utils.ProgrammingError: relation "extras_objectchange" does not exist
LINE 1: ...ct_type_id", "extras_objectchange"."user_id" FROM "extras_ob...

Content of docker-compose.override.yml

services:

  netbox:
    container_name: netbox
    build:
      context: /mnt/docker-storage/netbox-docker/netbox-custom
      tags:
        - "netbox:latest-custom"
    image: netbox:latest-custom
    pull_policy: build
    logging:
      driver: journald
      options:
        tag: "{{.Name}}"
    restart: unless-stopped
    networks:
      - default
    ports:
      - 8000:8080
    volumes: &netbox_volumes
      - /mnt/docker-storage/netbox-docker/netbox-custom/custom_config.py:/etc/netbox/config/custom_config.py:z,ro
    env_file: /mnt/docker-storage/netbox-docker/env/netbox.env
    labels:
      - "com.centurylinklabs.watchtower.enable=false"

  netbox-worker:
    container_name: netbox-worker
    image: netbox:latest-custom
    pull_policy: never
    logging:
      driver: journald
      options:
        tag: "{{.Name}}"
    restart: unless-stopped
    networks:
      - default
    volumes:
      *netbox_volumes
    env_file: /mnt/docker-storage/netbox-docker/env/netbox.env
    labels:
      - "com.centurylinklabs.watchtower.enable=false"

  netbox-housekeeping:
    container_name: netbox-housekeeping
    image: netbox:latest-custom
    pull_policy: never
    logging:
      driver: journald
      options:
        tag: "{{.Name}}"
    restart: unless-stopped
    networks:
      - default
    volumes:
      *netbox_volumes
    env_file: /mnt/docker-storage/netbox-docker/env/netbox.env
    labels:
      - "com.centurylinklabs.watchtower.enable=false"

  postgres:
    container_name: netbox-db
    logging:
      driver: journald
      options:
        tag: "{{.Name}}"
    restart: unless-stopped
    networks:
      - default
    env_file: /mnt/docker-storage/netbox-docker/env/postgres.env

  redis:
    container_name: netbox-redis
    logging:
      driver: journald
      options:
        tag: "{{.Name}}"
    restart: unless-stopped
    networks:
      - default
    env_file: /mnt/docker-storage/netbox-docker/env/redis.env

  redis-cache:
    container_name: netbox-redis-cache
    logging:
      driver: journald
      options:
        tag: "{{.Name}}"
    restart: unless-stopped
    networks:
      - default
    env_file: /mnt/docker-storage/netbox-docker/env/redis-cache.env

volumes:
  netbox-media-files:
    driver: local
    driver_opts:
      type: 'none'
      o: 'bind'
      device: '/mnt/docker-storage/netbox-docker/netbox-media-files'
  netbox-postgres-data:
    driver: local
    driver_opts:
      type: 'none'
      o: 'bind'
      device: '/mnt/docker-storage/netbox-docker/netbox-postgres-data'
  netbox-redis-cache-data:
    driver: local
    driver_opts:
      type: 'none'
      o: 'bind'
      device: '/mnt/docker-storage/netbox-docker/netbox-redis-cache-data'
  netbox-redis-data:
    driver: local
    driver_opts:
      type: 'none'
      o: 'bind'
      device: '/mnt/docker-storage/netbox-docker/netbox-redis-data'
  netbox-reports-files:
    driver: local
    driver_opts:
      type: 'none'
      o: 'bind'
      device: '/mnt/docker-storage/netbox-docker/netbox-reports-files'
  netbox-scripts-files:
    driver: local
    driver_opts:
      type: 'none'
      o: 'bind'
      device: '/mnt/docker-storage/netbox-docker/netbox-scripts-files'

networks:
  default:
    driver: bridge
    ipam:
      config:
        - subnet: "172.30.254.80/28"
avbor commented 1 month ago

Same discussions and issues: https://github.com/netbox-community/netbox/discussions/17382 https://github.com/netbox-community/netbox/discussions/17388 https://github.com/netbox-community/netbox/issues/17352

MrPaulAR commented 1 month ago

A direct link to what fixed for me in case someone stumbles across this.

I did the following