[PR #20349] [MERGED] Closes #20341: Drop legacy django_admin_log table #15904

Closed
opened 2025-12-30 00:24:42 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/20349
Author: @pheus
Created: 9/13/2025
Status: Merged
Merged: 9/13/2025
Merged by: @jnovinger

Base: mainHead: 20341-drop-legacy-django-admin-log-table-via-migration


📝 Commits (1)

  • a1ea3dd feat(users): Drop legacy django_admin_log table

📊 Changes

1 file changed (+22 additions, -0 deletions)

View changed files

netbox/users/migrations/0012_drop_django_admin_log_table.py (+22 -0)

📄 Description

Fixes: #20341

Older installations may still have the legacy django_admin_log table from the Django admin UI. These records can hold a foreign key to existing users and block their deletion. This PR adds a simple migration that drops the table (and its sequence) if they exist, unblocking user deletions on upgraded deployments.

Refs #20338

  • Drop legacy django_admin_log via raw SQL (DROP TABLE IF EXISTS).
  • Also drop leftover sequence (DROP SEQUENCE IF EXISTS).
  • Reverse is a no‑op; no models changed.

Testing

Verified end‑to‑end:

  1. Install fresh NetBox v3.7.8 (with Django Admin UI).
  2. Create a superuser and a user user1 with staff & superuser status.
  3. Log in as user1 and open Django Admin.
  4. Create a django_admin_log entry by creating a “nonce” with random values.
  5. Upgrade to NetBox v4.3.7.
  6. Try to delete user1 → FK error reproduced.
  7. Upgrade to NetBox v4.4.0 and apply this migration.
  8. Delete user1 successfully (no error).

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/20349 **Author:** [@pheus](https://github.com/pheus) **Created:** 9/13/2025 **Status:** ✅ Merged **Merged:** 9/13/2025 **Merged by:** [@jnovinger](https://github.com/jnovinger) **Base:** `main` ← **Head:** `20341-drop-legacy-django-admin-log-table-via-migration` --- ### 📝 Commits (1) - [`a1ea3dd`](https://github.com/netbox-community/netbox/commit/a1ea3dd048b3a834e44cb37c96b82ad47709227e) feat(users): Drop legacy `django_admin_log` table ### 📊 Changes **1 file changed** (+22 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `netbox/users/migrations/0012_drop_django_admin_log_table.py` (+22 -0) </details> ### 📄 Description <!-- Thank you for your interest in contributing to NetBox! Please note that our contribution policy requires that a feature request or bug report be approved and assigned prior to opening a pull request. This helps avoid waste time and effort on a proposed change that we might not be able to accept. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ISSUE WHICH HAS BEEN ASSIGNED TO YOU, IT WILL BE CLOSED AUTOMATICALLY. Please specify your assigned issue number on the line below. --> ### Fixes: #20341 Older installations may still have the legacy django_admin_log table from the Django admin UI. These records can hold a foreign key to existing users and block their deletion. This PR adds a simple migration that drops the table (and its sequence) if they exist, unblocking user deletions on upgraded deployments. Refs #20338 - Drop legacy `django_admin_log` via raw SQL (`DROP TABLE IF EXISTS`). - Also drop leftover sequence (`DROP SEQUENCE IF EXISTS`). - Reverse is a no‑op; no models changed. --- ### Testing Verified end‑to‑end: 1. Install fresh NetBox **v3.7.8** (with Django Admin UI). 2. Create a superuser and a user **user1** with staff & superuser status. 3. Log in as **user1** and open Django Admin. 4. Create a `django_admin_log` entry by creating a “nonce” with random values. 5. Upgrade to NetBox **v4.3.7**. 6. Try to delete **user1** → FK error reproduced. 7. Upgrade to NetBox **v4.4.0** and apply this migration. 8. Delete **user1** successfully (no error). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:24:42 +01:00
adam closed this issue 2025-12-30 00:24:43 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15904