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
2
2
3
+ from django .conf import settings
4
+ import django .contrib .postgres .fields
3
5
import django .core .validators
6
+ from django .db import migrations , models
4
7
import django .db .models .deletion
5
8
import taggit .managers
6
9
import utilities .json
7
- from django .db import migrations , models
8
10
9
11
10
12
class Migration (migrations .Migration ):
11
13
initial = True
12
14
13
15
dependencies = [
14
- ("extras" , "0092_delete_jobresult" ),
16
+ migrations .swappable_dependency (settings .AUTH_USER_MODEL ),
17
+ ("extras" , "0098_webhook_custom_field_data_webhook_tags" ),
15
18
]
16
19
17
20
operations = [
18
21
migrations .CreateModel (
19
- name = "ScriptExecution " ,
22
+ name = "ScriptInstance " ,
20
23
fields = [
21
24
("id" , models .BigAutoField (auto_created = True , primary_key = True , serialize = False )),
22
25
("created" , models .DateTimeField (auto_now_add = True , null = True )),
23
26
("last_updated" , models .DateTimeField (auto_now = True , null = True )),
24
27
("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 )),
25
52
("started" , models .DateTimeField (blank = True , null = True )),
26
53
("completed" , models .DateTimeField (blank = True , null = True )),
27
54
("status" , models .CharField (default = "pending" , max_length = 30 )),
28
55
("scheduled" , models .DateTimeField (blank = True , null = True )),
56
+ ("task_queue" , models .CharField (default = "default" , max_length = 100 )),
29
57
("interval" , models .PositiveIntegerField (blank = True , null = True , validators = [django .core .validators .MinValueValidator (1 )])),
30
58
("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
+ ),
32
75
],
33
76
options = {
34
- "ordering" : ("-started " ,),
77
+ "ordering" : ("-created " ,),
35
78
},
36
79
),
37
80
migrations .CreateModel (
38
- name = "ScriptInstance " ,
81
+ name = "ScriptArtifact " ,
39
82
fields = [
40
83
("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
+ ),
46
95
],
96
+ options = {
97
+ "ordering" : ("id" ,),
98
+ },
47
99
),
48
100
migrations .CreateModel (
49
101
name = "ScriptLogLine" ,
50
102
fields = [
51
103
("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 )),
55
104
("level" , models .CharField (max_length = 50 )),
56
105
("message" , models .TextField ()),
57
106
("timestamp" , models .DateTimeField (auto_now_add = True )),
@@ -63,42 +112,31 @@ class Migration(migrations.Migration):
63
112
to = "netbox_script_manager.scriptexecution" ,
64
113
),
65
114
),
66
- ("tags" , taggit .managers .TaggableManager (through = "extras.TaggedItem" , to = "extras.Tag" )),
67
115
],
68
116
options = {
69
117
"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
+ ],
70
122
},
71
123
),
72
124
migrations .AddIndex (
73
125
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 " ),
75
127
),
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"
81
132
),
82
133
),
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
- ),
96
134
migrations .AddIndex (
97
135
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 " ),
99
137
),
100
138
migrations .AddIndex (
101
139
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 " ),
103
141
),
104
142
]
0 commit comments