mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
#10560: Build search index as part of migration
This commit is contained in:
54
netbox/extras/migrations/0083_search.py
Normal file
54
netbox/extras/migrations/0083_search.py
Normal file
@@ -0,0 +1,54 @@
|
||||
import sys
|
||||
import uuid
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.core import management
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def reindex(apps, schema_editor):
|
||||
# Build the search index (except during tests)
|
||||
if 'test' not in sys.argv:
|
||||
management.call_command('reindex')
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('circuits', '0041_standardize_description_comments'),
|
||||
('contenttypes', '0002_remove_content_type_name'),
|
||||
('dcim', '0166_virtualdevicecontext'),
|
||||
('extras', '0082_savedfilter'),
|
||||
('ipam', '0063_standardize_description_comments'),
|
||||
('tenancy', '0009_standardize_description_comments'),
|
||||
('virtualization', '0034_standardize_description_comments'),
|
||||
('wireless', '0008_wirelesslan_status'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='customfield',
|
||||
name='search_weight',
|
||||
field=models.PositiveSmallIntegerField(default=1000),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='CachedValue',
|
||||
fields=[
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('timestamp', models.DateTimeField(auto_now_add=True)),
|
||||
('object_id', models.PositiveBigIntegerField()),
|
||||
('field', models.CharField(max_length=200)),
|
||||
('type', models.CharField(max_length=30)),
|
||||
('value', models.TextField(db_index=True)),
|
||||
('weight', models.PositiveSmallIntegerField(default=1000)),
|
||||
('object_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='contenttypes.contenttype')),
|
||||
],
|
||||
options={
|
||||
'ordering': ('weight', 'object_type', 'object_id'),
|
||||
},
|
||||
),
|
||||
migrations.RunPython(
|
||||
code=reindex,
|
||||
reverse_code=migrations.RunPython.noop
|
||||
),
|
||||
]
|
Reference in New Issue
Block a user