-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Plugin Version
v0.4.6
Proposed functionality
Important consideration: If changes are made to core mixins (the base classes that Custom Object models inherit from), there is currently no mechanism to generate migrations for the dynamically created Custom Object tables.
The Problem:
Custom Object models inherit from mixins like NetBoxModel, ChangeLoggingMixin, etc. When these core mixins are updated (e.g., new field added, field type changed), the changes need to propagate to:
- The dynamic Custom Object tables in the database
- Any related indexes, constraints, or triggers
Since Custom Objects don't have traditional migration files (they use runtime schema operations), there's no standard way to:
- Detect that a mixin has changed
- Generate the appropriate
ALTER TABLEstatements - Apply these changes across all existing Custom Object tables
Impact:
| Scenario | Current Behavior | Desired Behavior |
|---|---|---|
| New field added to mixin | Not applied to existing COT tables | Auto-detect and apply |
| Field type changed in mixin | Mismatch between model and table | Migration generated and applied |
| Index added to mixin | Missing on COT tables | Created on all COT tables |
| NetBox upgrade with mixin changes | Potential runtime errors | Seamless upgrade |
Possible Solutions:
- Mixin version tracking - Track which mixin version each COT was created with; compare on startup
- Schema introspection - Compare actual table schema to expected model schema; generate diffs
- Explicit upgrade command -
manage.py upgrade_custom_objectsthat applies pending mixin changes - Hook into NetBox migrations - Detect relevant core migrations and apply to COT tables
Use case
If changes are made to core mixins (the base classes that Custom Object models inherit from), there is currently no mechanism to generate migrations for the dynamically created Custom Object tables.
External dependencies
No response