From de36c6844c9c84b699e3c16e12af4e210632e4c9 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Tue, 3 Sep 2024 11:05:32 -0400 Subject: [PATCH] doorcontrol: Convert HIDEvent.raw_card_number to TextField Turns out that those are not just representing a uint, and can be much longer. Also Text fields in Postgres doesn't have any performance penalty. --- .../0002_alter_hidevent_raw_card_number.py | 17 +++++++++++++++++ doorcontrol/models.py | 4 +--- 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 doorcontrol/migrations/0002_alter_hidevent_raw_card_number.py diff --git a/doorcontrol/migrations/0002_alter_hidevent_raw_card_number.py b/doorcontrol/migrations/0002_alter_hidevent_raw_card_number.py new file mode 100644 index 0000000..1aa3c34 --- /dev/null +++ b/doorcontrol/migrations/0002_alter_hidevent_raw_card_number.py @@ -0,0 +1,17 @@ +# Generated by Django 5.1 on 2024-09-03 14:56 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("doorcontrol", "0001_initial"), + ] + + operations = [ + migrations.AlterField( + model_name="hidevent", + name="raw_card_number", + field=models.TextField(blank=True, db_column="rawCardNumber", null=True), + ), + ] diff --git a/doorcontrol/models.py b/doorcontrol/models.py index 6a1e7ca..c5e8ec4 100644 --- a/doorcontrol/models.py +++ b/doorcontrol/models.py @@ -159,9 +159,7 @@ class HIDEvent(models.Model): io_state = models.BooleanField(blank=True, null=True, db_column="ioState") new_time = models.DateTimeField(blank=True, null=True, db_column="newTime") old_time = models.DateTimeField(blank=True, null=True, db_column="oldTime") - raw_card_number = models.CharField( - max_length=8, blank=True, null=True, db_column="rawCardNumber" - ) + raw_card_number = models.TextField(blank=True, null=True, db_column="rawCardNumber") # Based on `function isRedEvent` from /html/hid-global.js on a HID EDGE EVO Solo is_red = models.GeneratedField(