1# Generated by Plain 0.52.2 on 2025-07-08 01:17
2
3import uuid
4
5from plain import models
6from plain.models import migrations
7
8
9class Migration(migrations.Migration):
10 initial = True
11
12 dependencies = []
13
14 operations = [
15 migrations.CreateModel(
16 name="Job",
17 fields=[
18 ("id", models.PrimaryKeyField()),
19 ("uuid", models.UUIDField(default=uuid.uuid4)),
20 ("created_at", models.DateTimeField(auto_now_add=True)),
21 ("started_at", models.DateTimeField(allow_null=True, required=False)),
22 ("job_request_uuid", models.UUIDField()),
23 ("job_class", models.CharField(max_length=255)),
24 ("parameters", models.JSONField(allow_null=True, required=False)),
25 ("priority", models.IntegerField(default=0)),
26 ("source", models.TextField(required=False)),
27 ("queue", models.CharField(default="default", max_length=255)),
28 ("retries", models.IntegerField(default=0)),
29 ("retry_attempt", models.IntegerField(default=0)),
30 ("unique_key", models.CharField(max_length=255, required=False)),
31 ],
32 options={
33 "ordering": ["-created_at"],
34 },
35 ),
36 migrations.CreateModel(
37 name="JobRequest",
38 fields=[
39 ("id", models.PrimaryKeyField()),
40 ("created_at", models.DateTimeField(auto_now_add=True)),
41 ("uuid", models.UUIDField(default=uuid.uuid4)),
42 ("job_class", models.CharField(max_length=255)),
43 ("parameters", models.JSONField(allow_null=True, required=False)),
44 ("priority", models.IntegerField(default=0)),
45 ("source", models.TextField(required=False)),
46 ("queue", models.CharField(default="default", max_length=255)),
47 ("retries", models.IntegerField(default=0)),
48 ("retry_attempt", models.IntegerField(default=0)),
49 ("unique_key", models.CharField(max_length=255, required=False)),
50 ("start_at", models.DateTimeField(allow_null=True, required=False)),
51 ],
52 options={
53 "ordering": ["priority", "-created_at"],
54 },
55 ),
56 migrations.CreateModel(
57 name="JobResult",
58 fields=[
59 ("id", models.PrimaryKeyField()),
60 ("uuid", models.UUIDField(default=uuid.uuid4)),
61 ("created_at", models.DateTimeField(auto_now_add=True)),
62 ("job_uuid", models.UUIDField()),
63 ("started_at", models.DateTimeField(allow_null=True, required=False)),
64 ("ended_at", models.DateTimeField(allow_null=True, required=False)),
65 ("error", models.TextField(required=False)),
66 (
67 "status",
68 models.CharField(
69 choices=[
70 ("SUCCESSFUL", "Successful"),
71 ("ERRORED", "Errored"),
72 ("CANCELLED", "Cancelled"),
73 ("LOST", "Lost"),
74 ],
75 max_length=20,
76 ),
77 ),
78 ("job_request_uuid", models.UUIDField()),
79 ("job_class", models.CharField(max_length=255)),
80 ("parameters", models.JSONField(allow_null=True, required=False)),
81 ("priority", models.IntegerField(default=0)),
82 ("source", models.TextField(required=False)),
83 ("queue", models.CharField(default="default", max_length=255)),
84 ("retries", models.IntegerField(default=0)),
85 ("retry_attempt", models.IntegerField(default=0)),
86 ("unique_key", models.CharField(max_length=255, required=False)),
87 (
88 "retry_job_request_uuid",
89 models.UUIDField(allow_null=True, required=False),
90 ),
91 ],
92 options={
93 "ordering": ["-created_at"],
94 },
95 ),
96 migrations.AddIndex(
97 model_name="job",
98 index=models.Index(
99 fields=["created_at"], name="plainworker_created_a02317_idx"
100 ),
101 ),
102 migrations.AddIndex(
103 model_name="job",
104 index=models.Index(fields=["queue"], name="plainworker_queue_077806_idx"),
105 ),
106 migrations.AddIndex(
107 model_name="job",
108 index=models.Index(
109 fields=["unique_key"], name="plainworker_unique__04d87b_idx"
110 ),
111 ),
112 migrations.AddIndex(
113 model_name="job",
114 index=models.Index(
115 fields=["started_at"], name="plainworker_started_143df5_idx"
116 ),
117 ),
118 migrations.AddIndex(
119 model_name="job",
120 index=models.Index(
121 fields=["job_class"], name="plainworker_job_cla_884b46_idx"
122 ),
123 ),
124 migrations.AddIndex(
125 model_name="job",
126 index=models.Index(
127 fields=["job_request_uuid"], name="plainworker_job_req_db2681_idx"
128 ),
129 ),
130 migrations.AddIndex(
131 model_name="job",
132 index=models.Index(
133 fields=["job_class", "unique_key"], name="job_class_unique_key"
134 ),
135 ),
136 migrations.AddConstraint(
137 model_name="job",
138 constraint=models.UniqueConstraint(
139 fields=("uuid",), name="plainworker_job_unique_uuid"
140 ),
141 ),
142 migrations.AddIndex(
143 model_name="jobrequest",
144 index=models.Index(
145 fields=["priority"], name="plainworker_priorit_785e73_idx"
146 ),
147 ),
148 migrations.AddIndex(
149 model_name="jobrequest",
150 index=models.Index(
151 fields=["created_at"], name="plainworker_created_c81fe5_idx"
152 ),
153 ),
154 migrations.AddIndex(
155 model_name="jobrequest",
156 index=models.Index(fields=["queue"], name="plainworker_queue_2614aa_idx"),
157 ),
158 migrations.AddIndex(
159 model_name="jobrequest",
160 index=models.Index(
161 fields=["start_at"], name="plainworker_start_a_4d6020_idx"
162 ),
163 ),
164 migrations.AddIndex(
165 model_name="jobrequest",
166 index=models.Index(
167 fields=["unique_key"], name="plainworker_unique__21a534_idx"
168 ),
169 ),
170 migrations.AddIndex(
171 model_name="jobrequest",
172 index=models.Index(
173 fields=["job_class"], name="plainworker_job_cla_3e7dea_idx"
174 ),
175 ),
176 migrations.AddIndex(
177 model_name="jobrequest",
178 index=models.Index(
179 fields=["job_class", "unique_key"], name="job_request_class_unique_key"
180 ),
181 ),
182 migrations.AddConstraint(
183 model_name="jobrequest",
184 constraint=models.UniqueConstraint(
185 condition=models.Q(("retry_attempt", 0), ("unique_key__gt", "")),
186 fields=("job_class", "unique_key"),
187 name="plainworker_jobrequest_unique_job_class_key",
188 ),
189 ),
190 migrations.AddConstraint(
191 model_name="jobrequest",
192 constraint=models.UniqueConstraint(
193 fields=("uuid",), name="plainworker_jobrequest_unique_uuid"
194 ),
195 ),
196 migrations.AddIndex(
197 model_name="jobresult",
198 index=models.Index(
199 fields=["created_at"], name="plainworker_created_6894c5_idx"
200 ),
201 ),
202 migrations.AddIndex(
203 model_name="jobresult",
204 index=models.Index(
205 fields=["job_uuid"], name="plainworker_job_uui_8307d1_idx"
206 ),
207 ),
208 migrations.AddIndex(
209 model_name="jobresult",
210 index=models.Index(
211 fields=["started_at"], name="plainworker_started_9bce76_idx"
212 ),
213 ),
214 migrations.AddIndex(
215 model_name="jobresult",
216 index=models.Index(
217 fields=["ended_at"], name="plainworker_ended_a_63caaf_idx"
218 ),
219 ),
220 migrations.AddIndex(
221 model_name="jobresult",
222 index=models.Index(fields=["status"], name="plainworker_status_a7ca35_idx"),
223 ),
224 migrations.AddIndex(
225 model_name="jobresult",
226 index=models.Index(
227 fields=["job_request_uuid"], name="plainworker_job_req_1e1bf2_idx"
228 ),
229 ),
230 migrations.AddIndex(
231 model_name="jobresult",
232 index=models.Index(
233 fields=["job_class"], name="plainworker_job_cla_d138b5_idx"
234 ),
235 ),
236 migrations.AddIndex(
237 model_name="jobresult",
238 index=models.Index(fields=["queue"], name="plainworker_queue_23d8fe_idx"),
239 ),
240 migrations.AddConstraint(
241 model_name="jobresult",
242 constraint=models.UniqueConstraint(
243 fields=("uuid",), name="plainworker_jobresult_unique_uuid"
244 ),
245 ),
246 ]