netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/free-netbox-cloud/
http://netboxlabs.com/oss/netbox/
Apache License 2.0
16.18k stars 2.59k forks source link

Migration error upgrading from 3.0.0 to 3.7.2 #15109

Closed jtraulle closed 9 months ago

jtraulle commented 9 months ago

Hello,

I have slightly the same problem when trying to upgrade from 3.0.0 to 3.7.2 than in https://github.com/netbox-community/netbox/discussions/14678 :

Operations to perform:
  Apply all migrations: account, admin, auth, circuits, contenttypes, core, dcim, django_rq, extras, ipam, sessions, social_django, taggit, tenancy, users, virtualization, vpn, wireless
Running migrations:
  Applying tenancy.0002_tenant_ordering... OK
  Applying extras.0062_clear_secrets_changelog...Skipping config initialization (database unavailable)
Traceback (most recent call last):
  File "/opt/netbox-3.7.2/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
  File "/opt/netbox-3.7.2/venv/lib/python3.10/site-packages/psycopg/cursor.py", line 732, in execute
    raise ex.with_traceback(None)
psycopg.errors.InFailedSqlTransaction: current transaction is aborted, commands ignored until end of transaction block

Postgres logged the following:

2024-02-10_19:40:19.45436 ERROR:  relation "core_configrevision" does not exist at character 136
2024-02-10_19:40:19.45440 STATEMENT:  SELECT "core_configrevision"."id", "core_configrevision"."created", "core_configrevision"."comment", "core_configrevision"."data" FROM "core_configrevision" ORDER BY "core_configrevision"."created" ASC LIMIT 1
2024-02-10_19:40:19.45548 ERROR:  current transaction is aborted, commands ignored until end of transaction block
2024-02-10_19:40:19.45549 STATEMENT:  DELETE FROM "extras_objectchange" WHERE "extras_objectchange"."id" IN (100, 99, 98, 97, 96)

executing python3 netbox/manage.py migrate extras 0102_move_configrevision does not solve the problem

(venv) root@sodium:/opt/netbox-3.7.2# python3 netbox/manage.py migrate extras 0102_move_configrevision
Operations to perform:
  Target specific migration: 0102_move_configrevision, from extras
Running migrations:
  Applying extras.0062_clear_secrets_changelog...Skipping config initialization (database unavailable)
Traceback (most recent call last):
  File "/opt/netbox-3.7.2/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
  File "/opt/netbox-3.7.2/venv/lib/python3.10/site-packages/psycopg/cursor.py", line 732, in execute
    raise ex.with_traceback(None)
psycopg.errors.InFailedSqlTransaction: current transaction is aborted, commands ignored until end of transaction block

output of showmigrations if this can help diagnose :

(venv) root@sodium:/opt/netbox-3.7.2# python3 netbox/manage.py showmigrations
account
 [ ] 0001_initial
admin
 [X] 0001_initial
 [X] 0002_logentry_remove_auto_add
 [X] 0003_logentry_add_action_flag_choices
auth
 [X] 0001_initial
 [X] 0002_alter_permission_name_max_length
 [X] 0003_alter_user_email_max_length
 [X] 0004_alter_user_username_opts
 [X] 0005_alter_user_last_login_null
 [X] 0006_require_contenttypes_0002
 [X] 0007_alter_validators_add_error_messages
 [X] 0008_alter_user_username_max_length
 [X] 0009_alter_user_last_name_max_length
 [X] 0010_alter_group_name_max_length
 [X] 0011_update_proxy_permissions
 [X] 0012_alter_user_first_name_max_length
circuits
 [X] 0001_squashed (1 squashed migrations)
 [X] 0002_squashed_0029 (28 squashed migrations)
 [ ] 0003_extend_tag_support
 [ ] 0004_rename_cable_peer
 [ ] 0032_provider_service_id
 [ ] 0033_standardize_id_fields
 [ ] 0034_created_datetimefield
 [ ] 0035_provider_asns
 [ ] 0036_circuit_termination_date_tags_custom_fields
 [ ] 0037_new_cabling_models
 [ ] 0038_cabling_cleanup
 [ ] 0039_unique_constraints
 [ ] 0040_provider_remove_deprecated_fields
 [ ] 0041_standardize_description_comments
 [ ] 0042_provideraccount
 [ ] 0043_circuittype_color
contenttypes
 [X] 0001_initial
 [X] 0002_remove_content_type_name
core
 [ ] 0001_initial
 [ ] 0002_managedfile
 [ ] 0003_job
 [ ] 0004_replicate_jobresults
 [ ] 0005_job_created_auto_now
 [ ] 0006_datasource_type_remove_choices
 [ ] 0007_job_add_error_field
 [ ] 0008_contenttype_proxy
 [ ] 0009_configrevision
 [ ] 0010_gfk_indexes
dcim
 [X] 0001_squashed (1 squashed migrations)
 [X] 0002_squashed (1 squashed migrations)
 [X] 0003_squashed_0130 (129 squashed migrations)
 [X] 0131_consoleport_speed
 [X] 0132_cable_length
 [X] 0133_port_colors
 [ ] 0134_interface_wwn_bridge
 [ ] 0135_tenancy_extensions
 [ ] 0136_device_airflow
 [ ] 0137_relax_uniqueness_constraints
 [ ] 0138_extend_tag_support
 [ ] 0139_rename_cable_peer
 [ ] 0140_wireless
 [ ] 0141_asn_model
 [ ] 0142_rename_128gfc_qsfp28
 [ ] 0143_remove_primary_for_related_name
 [ ] 0144_fix_cable_abs_length
 [ ] 0145_site_remove_deprecated_fields
 [ ] 0146_modules
 [ ] 0147_inventoryitemrole
 [ ] 0148_inventoryitem_component
 [ ] 0149_inventoryitem_templates
 [ ] 0150_interface_vrf
 [ ] 0151_interface_speed_duplex
 [ ] 0152_standardize_id_fields
 [ ] 0153_created_datetimefield
 [ ] 0154_half_height_rack_units
 [ ] 0155_interface_poe_mode_type
 [ ] 0156_location_status
 [ ] 0157_new_cabling_models
 [ ] 0158_populate_cable_terminations
 [ ] 0159_populate_cable_paths
 [ ] 0160_populate_cable_ends
 [ ] 0161_cabling_cleanup
 [ ] 0162_unique_constraints
 [ ] 0163_weight_fields
 [ ] 0164_rack_mounting_depth
 [ ] 0165_standardize_description_comments
 [ ] 0166_virtualdevicecontext
 [ ] 0167_module_status
 [ ] 0168_interface_template_enabled
 [ ] 0169_devicetype_default_platform
 [ ] 0170_configtemplate
 [ ] 0171_cabletermination_change_logging
 [ ] 0172_larger_power_draw_values
 [ ] 0173_remove_napalm_fields
 [ ] 0174_device_latitude_device_longitude
 [ ] 0174_rack_starting_unit
 [ ] 0175_device_oob_ip
 [ ] 0176_device_component_counters
 [ ] 0177_devicetype_component_counters
 [ ] 0178_virtual_chassis_member_counter
 [ ] 0179_interfacetemplate_rf_role
 [ ] 0180_powerfeed_tenant
 [ ] 0181_rename_device_role_device_role
 [ ] 0182_zero_length_cable_fix
 [ ] 0183_devicetype_exclude_from_utilization
 [ ] 0184_protect_child_interfaces
 [ ] 0185_gfk_indexes
django_rq
 [ ] 0001_initial
extras
 [X] 0001_squashed (1 squashed migrations)
 [X] 0002_squashed_0059 (58 squashed migrations)
 [X] 0060_customlink_button_class
 [X] 0061_extras_change_logging
 [ ] 0062_clear_secrets_changelog
 [ ] 0063_webhook_conditions
 [ ] 0064_configrevision
 [ ] 0065_imageattachment_change_logging
 [ ] 0066_customfield_name_validation
 [ ] 0067_customfield_min_max_values
 [ ] 0068_configcontext_cluster_types
 [ ] 0069_custom_object_field
 [ ] 0070_customlink_enabled
 [ ] 0071_standardize_id_fields
 [ ] 0072_created_datetimefield
 [ ] 0073_journalentry_tags_custom_fields
 [ ] 0074_customfield_extensions
 [ ] 0075_configcontext_locations
 [ ] 0076_tag_slug_unicode
 [ ] 0077_customlink_extend_text_and_url
 [ ] 0078_unique_constraints
 [ ] 0079_scheduled_jobs
 [ ] 0080_customlink_content_types
 [ ] 0081_exporttemplate_content_types
 [ ] 0082_savedfilter
 [ ] 0083_search
 [ ] 0084_staging
 [ ] 0085_synced_data
 [ ] 0086_configtemplate
 [ ] 0087_dashboard
 [ ] 0088_jobresult_webhooks
 [ ] 0089_customfield_is_cloneable
 [ ] 0090_objectchange_index_request_id
 [ ] 0091_create_managedfiles
 [ ] 0092_delete_jobresult
 [ ] 0093_configrevision_ordering
 [ ] 0094_tag_object_types
 [ ] 0095_bookmarks
 [ ] 0096_customfieldchoiceset
 [ ] 0097_customfield_remove_choices
 [ ] 0098_webhook_custom_field_data_webhook_tags
 [ ] 0099_cachedvalue_ordering
 [ ] 0100_customfield_ui_attrs
 [ ] 0101_eventrule
 [ ] 0102_move_configrevision
 [ ] 0103_gfk_indexes
 [ ] 0104_stagedchange_remove_change_logging
 [ ] 0105_customfield_min_max_values
 [ ] 0106_bookmark_user_cascade_deletion
ipam
 [X] 0001_squashed (1 squashed migrations)
 [X] 0002_squashed_0046 (45 squashed migrations)
 [X] 0047_prefix_depth_children
 [X] 0048_prefix_populate_depth_children
 [X] 0049_prefix_mark_utilized
 [X] 0050_iprange
 [ ] 0051_extend_tag_support
 [ ] 0052_fhrpgroup
 [ ] 0053_asn_model
 [ ] 0054_vlangroup_min_max_vids
 [ ] 0055_servicetemplate
 [ ] 0056_standardize_id_fields
 [ ] 0057_created_datetimefield
 [ ] 0058_ipaddress_nat_inside_nonunique
 [ ] 0059_l2vpn
 [ ] 0060_alter_l2vpn_slug
 [ ] 0061_fhrpgroup_name
 [ ] 0062_unique_constraints
 [ ] 0063_standardize_description_comments
 [ ] 0064_clear_search_cache
 [ ] 0065_asnrange
 [ ] 0066_iprange_mark_utilized
 [ ] 0067_ipaddress_index_host
 [ ] 0068_move_l2vpn
 [ ] 0069_gfk_indexes
sessions
 [X] 0001_initial
social_django
 [ ] 0001_initial (2 squashed migrations)
 [ ] 0002_add_related_name (2 squashed migrations)
 [ ] 0003_alter_email_max_length (2 squashed migrations)
 [ ] 0004_auto_20160423_0400 (2 squashed migrations)
 [ ] 0005_auto_20160727_2333 (1 squashed migrations)
 [ ] 0006_partial
 [ ] 0007_code_timestamp
 [ ] 0008_partial_timestamp
 [ ] 0009_auto_20191118_0520
 [ ] 0010_uid_db_index
 [ ] 0011_alter_id_fields
 [ ] 0012_usersocialauth_extra_data_new
 [ ] 0013_migrate_extra_data
 [ ] 0014_remove_usersocialauth_extra_data
 [ ] 0015_rename_extra_data_new_usersocialauth_extra_data
taggit
 [X] 0001_initial
 [X] 0002_auto_20150616_2121
 [X] 0003_taggeditem_add_unique_index
 [ ] 0004_alter_taggeditem_content_type_alter_taggeditem_tag
 [ ] 0005_auto_20220424_2025
 [ ] 0006_rename_taggeditem_content_type_object_id_taggit_tagg_content_8fc721_idx
tenancy
 [X] 0001_squashed_0012 (12 squashed migrations)
 [X] 0002_tenant_ordering
 [ ] 0003_contacts
 [ ] 0004_extend_tag_support
 [ ] 0005_standardize_id_fields
 [ ] 0006_created_datetimefield
 [ ] 0007_contact_link
 [ ] 0008_unique_constraints
 [ ] 0009_standardize_description_comments
 [ ] 0010_tenant_relax_uniqueness
 [ ] 0011_contactassignment_tags
 [ ] 0012_contactassignment_custom_fields
 [ ] 0013_gfk_indexes
 [ ] 0014_contactassignment_ordering
users
 [X] 0001_squashed_0011 (11 squashed migrations)
 [ ] 0002_standardize_id_fields
 [ ] 0003_token_allowed_ips_last_used
 [ ] 0004_netboxgroup_netboxuser
virtualization
 [X] 0001_squashed_0022 (22 squashed migrations)
 [X] 0023_virtualmachine_natural_ordering
 [ ] 0024_cluster_relax_uniqueness
 [ ] 0025_extend_tag_support
 [ ] 0026_vminterface_bridge
 [ ] 0027_standardize_id_fields
 [ ] 0028_vminterface_vrf
 [ ] 0029_created_datetimefield
 [ ] 0030_cluster_status
 [ ] 0031_virtualmachine_site_device
 [ ] 0032_virtualmachine_update_sites
 [ ] 0033_unique_constraints
 [ ] 0034_standardize_description_comments
 [ ] 0035_virtualmachine_interface_count
 [ ] 0036_virtualmachine_config_template
 [ ] 0037_protect_child_interfaces
 [ ] 0038_virtualdisk
vpn
 [ ] 0001_initial
 [ ] 0002_move_l2vpn
 [ ] 0003_ipaddress_multiple_tunnel_terminations
 [ ] 0004_alter_ikepolicy_mode
wireless
 [ ] 0001_wireless
 [ ] 0002_standardize_id_fields
 [ ] 0003_created_datetimefield
 [ ] 0004_wireless_tenancy
 [ ] 0005_wirelesslink_interface_types
 [ ] 0006_unique_constraints
 [ ] 0007_standardize_description_comments
 [ ] 0008_wirelesslan_status

Any idea what could cause that ?

Thanks for your help !

Originally posted by @jtraulle in https://github.com/netbox-community/netbox/discussions/14678#discussioncomment-8429357

jtraulle commented 9 months ago

Sorry, did not meant to create an issue but a new discussion.