1- # Generated by Django 4.1.9 on 2023-07-04 09:28
1+ # Generated by Django 4.2.4 on 2023-09-13 09:33
22
3+ from django .conf import settings
4+ import django .contrib .postgres .fields
35import django .core .validators
6+ from django .db import migrations , models
47import django .db .models .deletion
58import taggit .managers
69import utilities .json
7- from django .db import migrations , models
810
911
1012class Migration (migrations .Migration ):
1113 initial = True
1214
1315 dependencies = [
14- ("extras" , "0092_delete_jobresult" ),
16+ migrations .swappable_dependency (settings .AUTH_USER_MODEL ),
17+ ("extras" , "0098_webhook_custom_field_data_webhook_tags" ),
1518 ]
1619
1720 operations = [
1821 migrations .CreateModel (
19- name = "ScriptExecution " ,
22+ name = "ScriptInstance " ,
2023 fields = [
2124 ("id" , models .BigAutoField (auto_created = True , primary_key = True , serialize = False )),
2225 ("created" , models .DateTimeField (auto_now_add = True , null = True )),
2326 ("last_updated" , models .DateTimeField (auto_now = True , null = True )),
2427 ("custom_field_data" , models .JSONField (blank = True , default = dict , encoder = utilities .json .CustomFieldJSONEncoder )),
28+ ("description" , models .CharField (blank = True , max_length = 200 )),
29+ ("comments" , models .TextField (blank = True )),
30+ ("name" , models .CharField (max_length = 100 )),
31+ ("module_path" , models .CharField (max_length = 1000 )),
32+ ("class_name" , models .CharField (max_length = 1000 )),
33+ ("group" , models .CharField (blank = True , max_length = 100 , null = True )),
34+ ("weight" , models .PositiveSmallIntegerField (default = 1000 )),
35+ (
36+ "task_queues" ,
37+ django .contrib .postgres .fields .ArrayField (
38+ base_field = models .CharField (blank = True , max_length = 100 ), blank = True , default = list , size = None
39+ ),
40+ ),
41+ ("tags" , taggit .managers .TaggableManager (through = "extras.TaggedItem" , to = "extras.Tag" )),
42+ ],
43+ options = {
44+ "ordering" : ("group" , "weight" , "name" ),
45+ },
46+ ),
47+ migrations .CreateModel (
48+ name = "ScriptExecution" ,
49+ fields = [
50+ ("id" , models .BigAutoField (auto_created = True , primary_key = True , serialize = False )),
51+ ("created" , models .DateTimeField (auto_now_add = True )),
2552 ("started" , models .DateTimeField (blank = True , null = True )),
2653 ("completed" , models .DateTimeField (blank = True , null = True )),
2754 ("status" , models .CharField (default = "pending" , max_length = 30 )),
2855 ("scheduled" , models .DateTimeField (blank = True , null = True )),
56+ ("task_queue" , models .CharField (default = "default" , max_length = 100 )),
2957 ("interval" , models .PositiveIntegerField (blank = True , null = True , validators = [django .core .validators .MinValueValidator (1 )])),
3058 ("task_id" , models .UUIDField (unique = True )),
31- ("data" , models .JSONField (blank = True , null = True )),
59+ ("request_id" , models .UUIDField (unique = True )),
60+ ("data" , models .JSONField (blank = True , default = dict , null = True )),
61+ (
62+ "script_instance" ,
63+ models .ForeignKey (
64+ on_delete = django .db .models .deletion .CASCADE ,
65+ related_name = "script_executions" ,
66+ to = "netbox_script_manager.scriptinstance" ,
67+ ),
68+ ),
69+ (
70+ "user" ,
71+ models .ForeignKey (
72+ blank = True , null = True , on_delete = django .db .models .deletion .SET_NULL , related_name = "+" , to = settings .AUTH_USER_MODEL
73+ ),
74+ ),
3275 ],
3376 options = {
34- "ordering" : ("-started " ,),
77+ "ordering" : ("-created " ,),
3578 },
3679 ),
3780 migrations .CreateModel (
38- name = "ScriptInstance " ,
81+ name = "ScriptArtifact " ,
3982 fields = [
4083 ("id" , models .BigAutoField (auto_created = True , primary_key = True , serialize = False )),
41- ("created" , models .DateTimeField (auto_now_add = True , null = True )),
42- ("last_updated" , models .DateTimeField (auto_now = True , null = True )),
43- ("name" , models .CharField (max_length = 100 )),
44- ("module_path" , models .CharField (max_length = 1000 )),
45- ("class_name" , models .CharField (max_length = 1000 )),
84+ ("data" , models .BinaryField ()),
85+ ("name" , models .CharField (default = "text/plain" , max_length = 100 )),
86+ ("content_type" , models .CharField (max_length = 100 )),
87+ (
88+ "script_execution" ,
89+ models .ForeignKey (
90+ on_delete = django .db .models .deletion .CASCADE ,
91+ related_name = "script_artifacts" ,
92+ to = "netbox_script_manager.scriptexecution" ,
93+ ),
94+ ),
4695 ],
96+ options = {
97+ "ordering" : ("id" ,),
98+ },
4799 ),
48100 migrations .CreateModel (
49101 name = "ScriptLogLine" ,
50102 fields = [
51103 ("id" , models .BigAutoField (auto_created = True , primary_key = True , serialize = False )),
52- ("created" , models .DateTimeField (auto_now_add = True , null = True )),
53- ("last_updated" , models .DateTimeField (auto_now = True , null = True )),
54- ("custom_field_data" , models .JSONField (blank = True , default = dict , encoder = utilities .json .CustomFieldJSONEncoder )),
55104 ("level" , models .CharField (max_length = 50 )),
56105 ("message" , models .TextField ()),
57106 ("timestamp" , models .DateTimeField (auto_now_add = True )),
@@ -63,42 +112,31 @@ class Migration(migrations.Migration):
63112 to = "netbox_script_manager.scriptexecution" ,
64113 ),
65114 ),
66- ("tags" , taggit .managers .TaggableManager (through = "extras.TaggedItem" , to = "extras.Tag" )),
67115 ],
68116 options = {
69117 "ordering" : ("timestamp" ,),
118+ "indexes" : [
119+ models .Index (fields = ["level" ], name = "netbox_scri_level_8445b8_idx" ),
120+ models .Index (fields = ["timestamp" ], name = "netbox_scri_timesta_535a98_idx" ),
121+ ],
70122 },
71123 ),
72124 migrations .AddIndex (
73125 model_name = "scriptinstance" ,
74- index = models .Index (fields = ["name" ], name = "netbox_plug_name_564a70_idx " ),
126+ index = models .Index (fields = ["name" ], name = "netbox_scri_name_d36576_idx " ),
75127 ),
76- migrations .AddField (
77- model_name = "scriptexecution" ,
78- name = "script_instance" ,
79- field = models .ForeignKey (
80- on_delete = django .db .models .deletion .CASCADE , related_name = "script_executions" , to = "netbox_script_manager.scriptinstance"
128+ migrations .AddConstraint (
129+ model_name = "scriptinstance" ,
130+ constraint = models .UniqueConstraint (
131+ fields = ("module_path" , "class_name" ), name = "netbox_script_manager_scriptinstance_unique_module_path_class_name"
81132 ),
82133 ),
83- migrations .AddField (
84- model_name = "scriptexecution" ,
85- name = "tags" ,
86- field = taggit .managers .TaggableManager (through = "extras.TaggedItem" , to = "extras.Tag" ),
87- ),
88- migrations .AddIndex (
89- model_name = "scriptlogline" ,
90- index = models .Index (fields = ["level" ], name = "netbox_plug_level_8d819d_idx" ),
91- ),
92- migrations .AddIndex (
93- model_name = "scriptlogline" ,
94- index = models .Index (fields = ["timestamp" ], name = "netbox_plug_timesta_0d3feb_idx" ),
95- ),
96134 migrations .AddIndex (
97135 model_name = "scriptexecution" ,
98- index = models .Index (fields = ["started" ], name = "netbox_plug_started_b32370_idx " ),
136+ index = models .Index (fields = ["started" ], name = "netbox_scri_started_ca0f36_idx " ),
99137 ),
100138 migrations .AddIndex (
101139 model_name = "scriptexecution" ,
102- index = models .Index (fields = ["completed" ], name = "netbox_plug_complet_95a239_idx " ),
140+ index = models .Index (fields = ["completed" ], name = "netbox_scri_complet_0824df_idx " ),
103141 ),
104142 ]
0 commit comments