mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
* Closes #12129: Enable automatic synchronization of objects when DataFiles are updated * Cleanup
84 lines
4.0 KiB
Python
84 lines
4.0 KiB
Python
# Generated by Django 4.1.5 on 2023-02-02 02:37
|
|
|
|
import django.core.validators
|
|
from django.db import migrations, models
|
|
import django.db.models.deletion
|
|
import taggit.managers
|
|
import utilities.json
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
initial = True
|
|
|
|
dependencies = [
|
|
('extras', '0084_staging'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name='DataSource',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
|
|
('created', models.DateTimeField(auto_now_add=True, null=True)),
|
|
('last_updated', models.DateTimeField(auto_now=True, null=True)),
|
|
('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)),
|
|
('description', models.CharField(blank=True, max_length=200)),
|
|
('comments', models.TextField(blank=True)),
|
|
('name', models.CharField(max_length=100, unique=True)),
|
|
('type', models.CharField(default='local', max_length=50)),
|
|
('source_url', models.CharField(max_length=200)),
|
|
('status', models.CharField(default='new', editable=False, max_length=50)),
|
|
('enabled', models.BooleanField(default=True)),
|
|
('ignore_rules', models.TextField(blank=True)),
|
|
('parameters', models.JSONField(blank=True, null=True)),
|
|
('last_synced', models.DateTimeField(blank=True, editable=False, null=True)),
|
|
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
|
|
],
|
|
options={
|
|
'ordering': ('name',),
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='DataFile',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
|
|
('created', models.DateTimeField(auto_now_add=True)),
|
|
('last_updated', models.DateTimeField(editable=False)),
|
|
('path', models.CharField(editable=False, max_length=1000)),
|
|
('size', models.PositiveIntegerField(editable=False)),
|
|
('hash', models.CharField(editable=False, max_length=64, validators=[django.core.validators.RegexValidator(message='Length must be 64 hexadecimal characters.', regex='^[0-9a-f]{64}$')])),
|
|
('data', models.BinaryField()),
|
|
('source', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='datafiles', to='core.datasource')),
|
|
],
|
|
options={
|
|
'ordering': ('source', 'path'),
|
|
},
|
|
),
|
|
migrations.AddConstraint(
|
|
model_name='datafile',
|
|
constraint=models.UniqueConstraint(fields=('source', 'path'), name='core_datafile_unique_source_path'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='datafile',
|
|
index=models.Index(fields=['source', 'path'], name='core_datafile_source_path'),
|
|
),
|
|
migrations.CreateModel(
|
|
name='AutoSyncRecord',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
|
|
('object_id', models.PositiveBigIntegerField()),
|
|
('datafile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='core.datafile')),
|
|
('object_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='contenttypes.contenttype')),
|
|
],
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='autosyncrecord',
|
|
index=models.Index(fields=['object_type', 'object_id'], name='core_autosy_object__c17bac_idx'),
|
|
),
|
|
migrations.AddConstraint(
|
|
model_name='autosyncrecord',
|
|
constraint=models.UniqueConstraint(fields=('object_type', 'object_id'), name='core_autosyncrecord_object'),
|
|
),
|
|
]
|