From bbb1b5bc80157ab8733cde8ef4ba35254ee1057c Mon Sep 17 00:00:00 2001 From: Daniel Shafer Date: Thu, 20 Jun 2024 09:55:53 -0600 Subject: [PATCH 1/2] Update Field Type for Object/User ID This updates the field type to CharField with a max of 50 characters to be able to handle UUID as well as any other standard format for IDs --- vote/migrations/005_update_field_type.py | 23 +++++++++++++++++++++++ vote/models.py | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 vote/migrations/005_update_field_type.py diff --git a/vote/migrations/005_update_field_type.py b/vote/migrations/005_update_field_type.py new file mode 100644 index 0000000..7795ef1 --- /dev/null +++ b/vote/migrations/005_update_field_type.py @@ -0,0 +1,23 @@ +# Generated by Django 4.1.7 on 2023-04-02 07:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('vote', '0005_alter_vote_id'), + ] + + operations = [ + migrations.AlterField( + model_name='vote', + name='object_id', + field=models.CharField(max_length=50), + ), + migrations.AlterField( + model_name='vote', + name='user_id', + field=models.CharField(max_length=50), + ), + ] diff --git a/vote/models.py b/vote/models.py index 5c5baa9..ef9720e 100644 --- a/vote/models.py +++ b/vote/models.py @@ -27,9 +27,9 @@ class Vote(models.Model): DOWN: 'num_vote_down' } - user_id = models.BigIntegerField() + user_id = models.CharField(max_length=50) content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) - object_id = models.PositiveIntegerField() + object_id = models.CharField(max_length=50) content_object = GenericForeignKey() action = models.PositiveSmallIntegerField(default=UP) create_at = models.DateTimeField(auto_now_add=True) From eb52d7dd2ff1dd4638a070e7e59b84bec3b0aba2 Mon Sep 17 00:00:00 2001 From: Daniel Shafer Date: Thu, 20 Jun 2024 10:02:40 -0600 Subject: [PATCH 2/2] Fix migrations dependency --- vote/migrations/005_update_field_type.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vote/migrations/005_update_field_type.py b/vote/migrations/005_update_field_type.py index 7795ef1..6b16d7f 100644 --- a/vote/migrations/005_update_field_type.py +++ b/vote/migrations/005_update_field_type.py @@ -6,7 +6,7 @@ class Migration(migrations.Migration): dependencies = [ - ('vote', '0005_alter_vote_id'), + ('vote', '0004_auto_20170110_1150'), ] operations = [