From b53be71bb12660da0c410eca5b27012d8f33cc62 Mon Sep 17 00:00:00 2001
From: Ernesto Rico Schmidt <ernesto@helsinki.at>
Date: Tue, 18 Apr 2023 18:40:23 -0400
Subject: [PATCH] Make TextFields not nullable. The Right Way.

1. remove the fields
2. re-add the fields as not-nullable.
---
 program/migrations/0057_auto_20230419_0038.py | 37 ++++++++++++++++
 program/migrations/0058_auto_20230419_0039.py | 43 +++++++++++++++++++
 program/models.py                             | 12 +++---
 3 files changed, 86 insertions(+), 6 deletions(-)
 create mode 100644 program/migrations/0057_auto_20230419_0038.py
 create mode 100644 program/migrations/0058_auto_20230419_0039.py

diff --git a/program/migrations/0057_auto_20230419_0038.py b/program/migrations/0057_auto_20230419_0038.py
new file mode 100644
index 00000000..c4c62a1d
--- /dev/null
+++ b/program/migrations/0057_auto_20230419_0038.py
@@ -0,0 +1,37 @@
+# Generated by Django 3.2.18 on 2023-04-18 22:38
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('program', '0056_auto_20230419_0017'),
+    ]
+
+    operations = [
+        migrations.RemoveField(
+            model_name='category',
+            name='subtitle',
+        ),
+        migrations.RemoveField(
+            model_name='host',
+            name='biography',
+        ),
+        migrations.RemoveField(
+            model_name='note',
+            name='playlist',
+        ),
+        migrations.RemoveField(
+            model_name='note',
+            name='tags',
+        ),
+        migrations.RemoveField(
+            model_name='show',
+            name='description',
+        ),
+        migrations.RemoveField(
+            model_name='show',
+            name='internal_note',
+        ),
+    ]
diff --git a/program/migrations/0058_auto_20230419_0039.py b/program/migrations/0058_auto_20230419_0039.py
new file mode 100644
index 00000000..117cfbc5
--- /dev/null
+++ b/program/migrations/0058_auto_20230419_0039.py
@@ -0,0 +1,43 @@
+# Generated by Django 3.2.18 on 2023-04-18 22:39
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('program', '0057_auto_20230419_0038'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='category',
+            name='subtitle',
+            field=models.TextField(blank=True),
+        ),
+        migrations.AddField(
+            model_name='host',
+            name='biography',
+            field=models.TextField(blank=True),
+        ),
+        migrations.AddField(
+            model_name='note',
+            name='playlist',
+            field=models.TextField(blank=True),
+        ),
+        migrations.AddField(
+            model_name='note',
+            name='tags',
+            field=models.TextField(blank=True),
+        ),
+        migrations.AddField(
+            model_name='show',
+            name='description',
+            field=models.TextField(blank=True),
+        ),
+        migrations.AddField(
+            model_name='show',
+            name='internal_note',
+            field=models.TextField(blank=True),
+        ),
+    ]
diff --git a/program/models.py b/program/models.py
index 85f870fa..84fde7e5 100644
--- a/program/models.py
+++ b/program/models.py
@@ -54,7 +54,7 @@ class Category(models.Model):
     is_active = models.BooleanField(default=True)
     name = models.CharField(max_length=32)
     slug = models.SlugField(max_length=32, unique=True)
-    subtitle = models.TextField(blank=True, null=True)
+    subtitle = models.TextField(blank=True)
 
     class Meta:
         ordering = ("name",)
@@ -144,7 +144,7 @@ class Image(models.Model):
 
 
 class Host(models.Model):
-    biography = models.TextField(blank=True, null=True)
+    biography = models.TextField(blank=True)
     created_at = models.DateTimeField(auto_now_add=True)
     created_by = models.CharField(max_length=150)
     email = models.EmailField(blank=True)
@@ -204,7 +204,7 @@ class Show(models.Model):
     created_at = models.DateTimeField(auto_now_add=True)
     created_by = models.CharField(max_length=150)
     default_playlist_id = models.IntegerField(blank=True, null=True)
-    description = models.TextField(blank=True, null=True)
+    description = models.TextField(blank=True)
     email = models.EmailField(blank=True, null=True)
     funding_category = models.ForeignKey(
         FundingCategory,
@@ -215,7 +215,7 @@ class Show(models.Model):
     )
     hosts = models.ManyToManyField(Host, blank=True, related_name="shows")
     image = models.ForeignKey(Image, null=True, on_delete=models.CASCADE, related_name="shows")
-    internal_note = models.TextField(blank=True, null=True)
+    internal_note = models.TextField(blank=True)
     is_active = models.BooleanField(default=True)
     is_public = models.BooleanField(default=False)
     language = models.ManyToManyField(Language, blank=True, related_name="shows")
@@ -467,10 +467,10 @@ class Note(models.Model):
         related_name="notes",
         default=1,
     )
-    playlist = models.TextField(blank=True, null=True)
+    playlist = models.TextField(blank=True)
     slug = models.SlugField(max_length=32, unique=True)
     summary = models.TextField(blank=True)
-    tags = models.TextField(blank=True, null=True)
+    tags = models.TextField(blank=True)
     timeslot = models.OneToOneField(TimeSlot, on_delete=models.CASCADE, unique=True)
     title = models.CharField(max_length=128)
     updated_at = models.DateTimeField(auto_now=True, blank=True, null=True)
-- 
GitLab