From 479cde49fe671b8ab3fed41ef7ad21aa599616e3 Mon Sep 17 00:00:00 2001 From: Ernesto Rico Schmidt <ernesto@helsinki.at> Date: Tue, 18 Apr 2023 18:27:11 -0400 Subject: [PATCH] Make CharFields not nullable. The Right Way. 1. remove the fields 2. re-add the fields as not-nullable. --- program/migrations/0055_auto_20230419_0015.py | 29 ++++++++++++++++ program/migrations/0056_auto_20230419_0017.py | 33 +++++++++++++++++++ program/models.py | 8 ++--- 3 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 program/migrations/0055_auto_20230419_0015.py create mode 100644 program/migrations/0056_auto_20230419_0017.py diff --git a/program/migrations/0055_auto_20230419_0015.py b/program/migrations/0055_auto_20230419_0015.py new file mode 100644 index 00000000..35487393 --- /dev/null +++ b/program/migrations/0055_auto_20230419_0015.py @@ -0,0 +1,29 @@ +# Generated by Django 3.2.18 on 2023-04-18 22:15 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('program', '0054_alter_schedule_last_date'), + ] + + operations = [ + migrations.RemoveField( + model_name='host', + name='updated_by', + ), + migrations.RemoveField( + model_name='note', + name='updated_by', + ), + migrations.RemoveField( + model_name='show', + name='updated_by', + ), + migrations.RemoveField( + model_name='userprofile', + name='updated_by', + ), + ] diff --git a/program/migrations/0056_auto_20230419_0017.py b/program/migrations/0056_auto_20230419_0017.py new file mode 100644 index 00000000..82cf8c58 --- /dev/null +++ b/program/migrations/0056_auto_20230419_0017.py @@ -0,0 +1,33 @@ +# Generated by Django 3.2.18 on 2023-04-18 22:17 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('program', '0055_auto_20230419_0015'), + ] + + operations = [ + migrations.AddField( + model_name='host', + name='updated_by', + field=models.CharField(blank=True, default='', max_length=150), + ), + migrations.AddField( + model_name='note', + name='updated_by', + field=models.CharField(blank=True, default='', max_length=150), + ), + migrations.AddField( + model_name='show', + name='updated_by', + field=models.CharField(blank=True, default='', max_length=150), + ), + migrations.AddField( + model_name='userprofile', + name='updated_by', + field=models.CharField(blank=True, default='', max_length=150), + ), + ] diff --git a/program/models.py b/program/models.py index 62acfbc7..85f870fa 100644 --- a/program/models.py +++ b/program/models.py @@ -152,7 +152,7 @@ class Host(models.Model): is_active = models.BooleanField(default=True) name = models.CharField(max_length=128) updated_at = models.DateTimeField(auto_now=True, blank=True, null=True) - updated_by = models.CharField(blank=True, max_length=150, null=True) + updated_by = models.CharField(blank=True, default="", max_length=150) class Meta: ordering = ("name",) @@ -244,7 +244,7 @@ class Show(models.Model): Type, blank=True, null=True, on_delete=models.CASCADE, related_name="shows" ) updated_at = models.DateTimeField(auto_now=True, blank=True, null=True) - updated_by = models.CharField(blank=True, max_length=150, null=True) + updated_by = models.CharField(blank=True, default="", max_length=150) class Meta: ordering = ("slug",) @@ -474,7 +474,7 @@ class Note(models.Model): 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) - updated_by = models.CharField(blank=True, max_length=150, null=True) + updated_by = models.CharField(blank=True, default="", max_length=150) class Meta: ordering = ("timeslot",) @@ -500,7 +500,7 @@ class UserProfile(models.Model): created_at = models.DateTimeField(auto_now_add=True) created_by = models.CharField(max_length=150) updated_at = models.DateTimeField(auto_now=True, blank=True, null=True) - updated_by = models.CharField(blank=True, max_length=150, null=True) + updated_by = models.CharField(blank=True, default="", max_length=150) user = models.OneToOneField( User, on_delete=models.CASCADE, -- GitLab