Skip to content

Commit 49267c3

Browse files
committed
Replicate dcim_cablepath table for branch
1 parent d45bc99 commit 49267c3

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

netbox_branching/constants.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
# URL query parameter name
1111
QUERY_PARAM = '_branch'
1212

13+
# Tables which must be replicated within a branch even though their
14+
# models don't directly support branching.
15+
REPLICATE_TABLES = (
16+
'dcim_cablepath',
17+
)
18+
1319
# Models for which branching support is explicitly disabled
1420
EXEMPT_MODELS = (
1521
# Exempt applicable core NetBox models

netbox_branching/database.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ def _get_db(self, model, **hints):
2121
warnings.warn(f"Routing database query for {model} before branching support is initialized.")
2222
return
2323

24-
# Bail if the model does not support branching
25-
app_label, model_name = model._meta.label.lower().split('.')
26-
if model_name not in registry['model_features']['branching'].get(app_label, []):
27-
return
28-
2924
# Return the schema for the active branch (if any)
3025
if branch := active_branch.get():
3126
return f'schema_{branch.schema_name}'

netbox_branching/utilities.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from django.db.models import ForeignKey, ManyToManyField
77
from django.urls import reverse
88

9+
from .constants import REPLICATE_TABLES
910
from .contextvars import active_branch
1011

1112
__all__ = (
@@ -81,9 +82,9 @@ def get_branchable_object_types():
8182

8283
def get_tables_to_replicate():
8384
"""
84-
Returned an ordered list of database tables to replicate when provisioning a new schema.
85+
Return an ordered list of database tables to replicate when provisioning a new schema.
8586
"""
86-
tables = set()
87+
tables = set(REPLICATE_TABLES)
8788

8889
branch_aware_models = [
8990
ot.model_class() for ot in get_branchable_object_types()

0 commit comments

Comments
 (0)