Skip to content

Commit 725743d

Browse files
committed
Convert columns to postgres enums
1 parent b77b4c4 commit 725743d

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Generated by Django 3.2.25 on 2024-12-19 19:58
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('commitfest', '0007_cfbot_add_scheduled'),
10+
]
11+
12+
operations = [
13+
migrations.RunSQL(
14+
"""
15+
CREATE TYPE cfbotbranch_status AS ENUM (
16+
'testing',
17+
'finished',
18+
'failed',
19+
'timeout'
20+
);
21+
"""
22+
),
23+
migrations.RunSQL(
24+
"""
25+
CREATE TYPE cfbottask_status AS ENUM (
26+
'CREATED',
27+
'NEEDS_APPROVAL',
28+
'TRIGGERED',
29+
'EXECUTING',
30+
'FAILED',
31+
'COMPLETED',
32+
'SCHEDULED',
33+
'ABORTED',
34+
'ERRORED'
35+
);
36+
"""
37+
),
38+
migrations.RunSQL(
39+
"""
40+
ALTER TABLE commitfest_cfbotbranch
41+
ALTER COLUMN status TYPE cfbotbranch_status
42+
USING status::cfbotbranch_status;
43+
"""
44+
),
45+
migrations.RunSQL(
46+
"""
47+
ALTER TABLE commitfest_cfbottask
48+
ALTER COLUMN status TYPE cfbottask_status
49+
USING status::cfbottask_status;
50+
"""
51+
),
52+
]

pgcommitfest/commitfest/models.py

+2
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ class CfbotBranch(models.Model):
356356
branch_name = models.TextField(null=False)
357357
commit_id = models.TextField(null=True, blank=True)
358358
apply_url = models.TextField(null=False)
359+
# Actually a postgres enum column
359360
status = models.TextField(choices=STATUS_CHOICES, null=False)
360361
created = models.DateTimeField(auto_now_add=True)
361362
modified = models.DateTimeField(auto_now=True)
@@ -379,6 +380,7 @@ class CfbotTask(models.Model):
379380
patch = models.ForeignKey(Patch, on_delete=models.CASCADE, related_name="cfbot_tasks")
380381
branch_id = models.IntegerField(null=False)
381382
position = models.IntegerField(null=False)
383+
# Actually a postgres enum column
382384
status = models.TextField(choices=STATUS_CHOICES, null=False)
383385
created = models.DateTimeField(auto_now_add=True)
384386
modified = models.DateTimeField(auto_now=True)

0 commit comments

Comments
 (0)