From 96338c002b3d3e797f29b6cfa7ecde595d0387ea Mon Sep 17 00:00:00 2001 From: Peter Eckel Date: Thu, 27 Jun 2024 17:19:14 +0000 Subject: [PATCH] Updated the documentation section about removing plugins --- docs/plugins/removal.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/plugins/removal.md b/docs/plugins/removal.md index f5e81bdc0..37228a939 100644 --- a/docs/plugins/removal.md +++ b/docs/plugins/removal.md @@ -70,3 +70,19 @@ DROP TABLE netbox=> DROP TABLE pluginname_bar; DROP TABLE ``` + +### Remove the Django Migration Records + +After removing the tables created by a plugin, the migrations that created the tables need to be removed from Django's migration history as well. This is necessary to make it possible to reinstall the plugin at a later time. If the migration history were left in place, Django would skip all migrations that were executed in the course of a previous installation, which would cause the plugin to fail after reinstallation. + +```no-highlight +netbox=> SELECT * FROM django_migrations WHERE app='pluginname'; + id | app | name | applied +-----+------------+------------------------+------------------------------- + 492 | pluginname | 0001_initial | 2023-12-21 11:59:59.325995+00 + 493 | pluginname | 0002_add_foo | 2023-12-21 11:59:59.330026+00 +netbox=> DELETE FROM django_migrations WHERE app='pluginname'; +``` + +!!! warning + Exercise extreme caution when altering Django system tables. Users are strongly encouraged to perform a backup of their database immediately before taking these actions.