[PR #11331] [MERGED] Fixes #11223 & #11248 - Reindex app label #13769

Closed
opened 2025-12-29 23:20:41 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/11331
Author: @Alef-Burzmali
Created: 12/28/2022
Status: Merged
Merged: 12/28/2022
Merged by: @jeremystretch

Base: developHead: 11223-reindex-app_label


📝 Commits (2)

📊 Changes

2 files changed (+30 additions, -10 deletions)

View changed files

📝 netbox/extras/management/commands/reindex.py (+20 -9)
📝 netbox/extras/migrations/0083_search.py (+10 -1)

📄 Description

Fixes: #11223 and #11248

Add the possibility to reindex all the models of an app_label via the management command reindex.

The second commit modifies the reindex call in migration extras.0083_search to reindex only the models of core NetBox, to prevent plugins from blocking the migration as in #11248. Plugins should add their own reindex migration when they add a SearchIndex, such as:

import sys

from django.core import management
from django.db import migrations

def reindex(apps, schema_editor):
    # Build the search index (except during tests)
    if "test" not in sys.argv:
        management.call_command("reindex", "<plugin_label>")

class Migration(migrations.Migration):
    dependencies = [
        ("<plugin_label>", "<NNNN_previous_migration>"),
    ]

    operations = [
        migrations.RunPython(
            code=reindex, reverse_code=migrations.RunPython.noop
        ),
    ]

🔄 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/11331 **Author:** [@Alef-Burzmali](https://github.com/Alef-Burzmali) **Created:** 12/28/2022 **Status:** ✅ Merged **Merged:** 12/28/2022 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `11223-reindex-app_label` --- ### 📝 Commits (2) - [`c4a92c4`](https://github.com/netbox-community/netbox/commit/c4a92c428b42ed8bd2cc860ac583a71b0ed51f81) Fixes #11223 - Accept app_label for reindex - [`cb7905c`](https://github.com/netbox-community/netbox/commit/cb7905c1ae3cb13ad791550c90bd87165ae6603b) Fixes #11248 - Reindex only NetBox apps ### 📊 Changes **2 files changed** (+30 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `netbox/extras/management/commands/reindex.py` (+20 -9) 📝 `netbox/extras/migrations/0083_search.py` (+10 -1) </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: #11223 and #11248 Add the possibility to reindex all the models of an app_label via the management command reindex. The second commit modifies the reindex call in migration extras.0083_search to reindex only the models of core NetBox, to prevent plugins from blocking the migration as in #11248. Plugins should add their own reindex migration when they add a SearchIndex, such as: ```python import sys from django.core import management from django.db import migrations def reindex(apps, schema_editor): # Build the search index (except during tests) if "test" not in sys.argv: management.call_command("reindex", "<plugin_label>") class Migration(migrations.Migration): dependencies = [ ("<plugin_label>", "<NNNN_previous_migration>"), ] operations = [ migrations.RunPython( code=reindex, reverse_code=migrations.RunPython.noop ), ] ``` --- <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-29 23:20:41 +01:00
adam closed this issue 2025-12-29 23:20:41 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13769