Add guidance to remove plugin entries from django_migrations table in plugins/removal.md #9840

Closed
opened 2025-12-29 21:23:26 +01:00 by adam · 4 comments
Owner

Originally created by @dberg918 on GitHub (Jun 13, 2024).

Originally assigned to: @dberg918 on GitHub.

Change Type

Addition

Area

Plugins

Proposed Changes

Recently I upgraded my Netbox instance to 4.x and had to remove the netbox-topology-views plugin since the beta was not ready yet. I followed the instructions in the documentation to remove the plugin from the configuration and to drop the tables it created in the netbox database and everything seemed fine.

After the beta version of the plugin was released last week, I decided to try it out. The installation worked fine, but when running the manage.py migrate netbox_topology_views command, it did not repopulate the tables in the netbox database. As a result, the plugin threw errors complaining that the requisite tables did not exist in the database, and running upgrades similarly failed with an identical error message. Eventually, I figured out this was because there were still entries for netbox_topology_views in my django_migrations table. After I removed these, the migrations worked correctly and populated the database with the necessary tables.

I'd like to propose adding a small section to the end of the "Removing a Plugin" section that includes deleting entries in the django_migrations table. I've written a sample below:


Also check for entries in the django_migrations table using the same pluginname:

netbox=> select * from django_migrations where app = 'pluginname';
id  |    app     |          name           |            applied
----+------------+-------------------------+-------------------------------
100 | pluginname | 0001_initial            | 1970-01-01 00:00:00.000000-05
101 | pluginname | 0002_pluginname_options | 1970-01-01 00:00:00.000001-05
(2 rows)

Drop the entries in the django_migrations table if they exist:

netbox=> delete from django_migrations where app = 'pluginname';
Originally created by @dberg918 on GitHub (Jun 13, 2024). Originally assigned to: @dberg918 on GitHub. ### Change Type Addition ### Area Plugins ### Proposed Changes Recently I upgraded my Netbox instance to 4.x and had to remove the netbox-topology-views plugin since the beta was not ready yet. I followed the instructions in the documentation to remove the plugin from the configuration and to drop the tables it created in the netbox database and everything seemed fine. After the beta version of the plugin was released last week, I decided to try it out. The installation worked fine, but when running the `manage.py migrate netbox_topology_views` command, it did not repopulate the tables in the netbox database. As a result, the plugin threw errors complaining that the requisite tables did not exist in the database, and running upgrades similarly failed with an identical error message. Eventually, I figured out this was because there were still entries for `netbox_topology_views` in my `django_migrations` table. After I removed these, the migrations worked correctly and populated the database with the necessary tables. I'd like to propose adding a small section to the end of the "Removing a Plugin" section that includes deleting entries in the `django_migrations` table. I've written a sample below: --- Also check for entries in the `django_migrations` table using the same `pluginname`: ```no-highlight netbox=> select * from django_migrations where app = 'pluginname'; id | app | name | applied ----+------------+-------------------------+------------------------------- 100 | pluginname | 0001_initial | 1970-01-01 00:00:00.000000-05 101 | pluginname | 0002_pluginname_options | 1970-01-01 00:00:00.000001-05 (2 rows) ``` Drop the entries in the `django_migrations` table if they exist: ```no-highlight netbox=> delete from django_migrations where app = 'pluginname'; ```
adam added the status: acceptedtype: documentation labels 2025-12-29 21:23:26 +01:00
adam closed this issue 2025-12-29 21:23:26 +01:00
Author
Owner

@a084ed22 commented on GitHub (Jun 13, 2024):

If your issue is related only to plugins not yet supporting netbox 4.x, there's no need to delete the data structures they have in the database, it's sufficient to comment out the plugin-related content in configuration.py. These instructions may however be useful if you want to uninstall the plugin and purge its contents from the database.

@a084ed22 commented on GitHub (Jun 13, 2024): If your issue is related only to plugins not yet supporting netbox 4.x, there's no need to delete the data structures they have in the database, it's sufficient to comment out the plugin-related content in configuration.py. These instructions may however be useful if you want to uninstall the plugin _and_ purge its contents from the database.
Author
Owner

@dberg918 commented on GitHub (Jun 13, 2024):

I had to re-read your comment a few times to understand your point. Yes, if you just want to remove a plugin temporarily while you wait for it to support the new version, commenting it out in configuration.py is enough. However, the documentation does not delineate between removing a plugin temporarily and removing a plugin permanently.

Either way, I think if it provides instructions on how to drop a plugin's tables from the database, it should also provide instructions to remove its entries from the django_migrations table since they go hand-in-hand. Otherwise, the plugin will be broken if the user ever decides to re-install it.

@dberg918 commented on GitHub (Jun 13, 2024): I had to re-read your comment a few times to understand your point. Yes, if you just want to remove a plugin temporarily while you wait for it to support the new version, commenting it out in `configuration.py` is enough. However, the documentation does not delineate between removing a plugin _temporarily_ and removing a plugin _permanently_. Either way, I think if it provides instructions on how to drop a plugin's tables from the database, it should also provide instructions to remove its entries from the `django_migrations` table since they go hand-in-hand. Otherwise, the plugin will be broken if the user ever decides to re-install it.
Author
Owner

@dberg918 commented on GitHub (Jun 17, 2024):

I can submit a pull request, but I need to have this issue assigned to me first and it looks like I can't do it myself. @arthanson would you be able to assist?

@dberg918 commented on GitHub (Jun 17, 2024): I can submit a pull request, but I need to have this issue assigned to me first and it looks like I can't do it myself. @arthanson would you be able to assist?
Author
Owner

@dberg918 commented on GitHub (Jul 29, 2024):

@peteeckel actually raised the same issue with #16748 and got a fixed merged last month, so this can be closed.

@dberg918 commented on GitHub (Jul 29, 2024): @peteeckel actually raised the same issue with #16748 and got a fixed merged last month, so this can be closed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9840