diff --git a/netbox_branching/constants.py b/netbox_branching/constants.py index d90e811..10e3c40 100644 --- a/netbox_branching/constants.py +++ b/netbox_branching/constants.py @@ -14,6 +14,7 @@ # must be replicated for each branch to ensure proper functionality INCLUDE_MODELS = ( 'dcim.cablepath', + 'extras.cachedvalue', ) # Models for which branching support is explicitly disabled diff --git a/netbox_branching/models/branches.py b/netbox_branching/models/branches.py index 624ac06..882e6e6 100644 --- a/netbox_branching/models/branches.py +++ b/netbox_branching/models/branches.py @@ -518,15 +518,15 @@ def provision(self, user): cursor.execute( f"INSERT INTO {schema_table} SELECT * FROM {main_table}" ) - # Get the name of the sequence used for object ID allocations + # Get the name of the sequence used for object ID allocations (if one exists) cursor.execute( "SELECT pg_get_serial_sequence(%s, 'id')", [table] ) - sequence_name = cursor.fetchone()[0] # Set the default value for the ID column to the sequence associated with the source table - cursor.execute( - f"ALTER TABLE {schema_table} ALTER COLUMN id SET DEFAULT nextval(%s)", [sequence_name] - ) + if sequence_name := cursor.fetchone()[0]: + cursor.execute( + f"ALTER TABLE {schema_table} ALTER COLUMN id SET DEFAULT nextval(%s)", [sequence_name] + ) # Commit the transaction cursor.execute("COMMIT")