You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that any time you need to perform database migrations (such as when upgrading Nautobot or Dolt) you **absolutely must comment out/disable `DATABASE_ROUTERS` from your `nautobot_config.py`** or you will encounter errors.
@@ -226,4 +226,4 @@ To be written
226
226
227
227
### Version Control Installation (migrating an existing Nautobot install)
The business logic to handle branch selection is performed in [middleware](https://docs.djangoproject.com/en/stable/topics/http/middleware/),
49
-
specifically in [DoltBranchMiddleware](https://github.com/nautobot/nautobot-plugin-version-control/blob/develop/dolt/middleware.py#L36)
49
+
specifically in [DoltBranchMiddleware](https://github.com/nautobot/nautobot-plugin-version-control/blob/develop/nautobot_version_control/middleware.py#L36)
50
50
51
51
## Database Versioning
52
52
@@ -55,8 +55,8 @@ Database connections outside of the web server, such as through nbshell are also
55
55
When connecting directly to the database you can check your current branch with the active_branch() function and switch branches with the checkout() method:
DoltAutoCommitMiddleWare wraps every server request in a [AutoDoltCommit](https://github.com/nautobot/nautobot-plugin-version-control/blob/develop/dolt/middleware.py#L134)
DoltAutoCommitMiddleWare wraps every server request in a [AutoDoltCommit](https://github.com/nautobot/nautobot-plugin-version-control/blob/develop/nautobot_version_control/middleware.py#L134)
138
138
context manager which listens for and responds to database writes made while processing the request.
139
139
AutoDoltCommit listens for signals fired by Django model updates and makes a Dolt commit if updates were made during the lifetime of the context manager.
140
140
The message for the commit is derived from the model signals that were captured.
is an abstract base class that forms the basis of Django models that expose Dolt system tables
146
146
to the Object Relational Mapping (ORM).
147
-
Plugin models such as *Commit* and *Branch* that inherit from DoltSystemTable are [unmanaged](https://github.com/nautobot/nautobot-plugin-version-control/blob/develop/dolt/models.py#L31
147
+
Plugin models such as *Commit* and *Branch* that inherit from DoltSystemTable are [unmanaged](https://github.com/nautobot/nautobot-plugin-version-control/blob/develop/nautobot_version_control/models.py#L31
148
148
meaning that Django will ignore these models for the purposes of database migrations.
149
149
This is important because Dolt system tables exist from the time the database is created and cannot be modified or deleted.
150
150
Internally, Dolt generates system table data on-the-fly rather than reading it from a traditional database index.
@@ -154,7 +154,7 @@ Internally, Dolt generates system table data on-the-fly rather than reading it f
154
154
The Branch model is one such "unmanaged" model.
155
155
It exposes the dolt_branches system table to the ORM.
156
156
System tables have a static schema, so additional object fields such as "created by" and "source branch" must be stored in another model.
157
-
The [BranchMeta](https://github.com/nautobot/nautobot-plugin-version-control/blob/develop/dolt/models.py#L205) model does exactly that.
157
+
The [BranchMeta](https://github.com/nautobot/nautobot-plugin-version-control/blob/develop/nautobot_version_control/models.py#L205) model does exactly that.
158
158
Each Branch object has an associated BranchMeta object where the `BranchMeta.branch field` is equal to the name field of the associated branch.
159
159
However, this relationship is not formalized with a Foreign Key due to limitations with the dolt_branches table.
160
160
Branch objects lookup their associated BranchMeta objects on a best-effort basis.
@@ -194,15 +194,15 @@ Non-versioned models:
194
194
## Global State Router
195
195
196
196
The business logic for differentiating versioned and non-versioned models is implemented in a Django [database router](https://docs.djangoproject.com/en/stable/topics/db/multi-db/#automatic-database-routing),
197
-
specifically the [GlobalStateRouter](https://github.com/nautobot/nautobot-plugin-version-control/blob/develop/dolt/routers.py#L10).
197
+
specifically the [GlobalStateRouter](https://github.com/nautobot/nautobot-plugin-version-control/blob/develop/nautobot_version_control/routers.py#L10).
198
198
The GlobalStateRouter is responsible for choosing a database connection to read an object from or write an object to, depending on its model class.
199
199
There are two connections to choose from when accessing the database.
200
200
The “default” connection will access the database on the Dolt branch that was specified in the request.
201
201
This connection is used to read and write versioned models.
202
202
The “global” connection always accesses the database on the main branch, it is used for non-versioned models.
203
203
204
204
In order to choose a connection for a model, the router first references the
205
-
[versioned model registry](https://github.com/nautobot/nautobot-plugin-version-control/blob/develop/dolt/__init__.py#L87)
205
+
[versioned model registry](https://github.com/nautobot/nautobot-plugin-version-control/blob/develop/nautobot_version_control/__init__.py#L87)
206
206
to determine if the model is under version control.
207
207
Currently, this registry is a hardcoded mapping from ContentType to versioned/non-versioned.
208
208
The versioned model registry is structured as an ["allow-list"](https://help.dnsfilter.com/hc/en-us/articles/1500008111381-Allow-and-Block-Lists).
@@ -211,7 +211,7 @@ If a model is absent from the list, it is assumed to be non-versioned.
211
211
in Nautobot core will make it possible for models to declare themselves whether they should be version controlled.
212
212
213
213
Database connections for versioned and non-versioned models are defined in
0 commit comments