Fix discord_id type mismatch between model (CharField) and migration (BIGINT) #78
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/major-domo-database#78
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
CustomCommandCreator.discord_idis declared asCharField(max_length=20, unique=True)in the model (db_engine.pyline 2227) but the migration created it asBIGINT UNIQUE NOT NULL.The ORM sends values as quoted strings while the column is integer. PostgreSQL will implicitly cast, but this prevents index usage and is a data consistency risk.
Fix
Align the model and migration — either change the model to
BigIntegerFieldor alter the column toVARCHAR(20). Discord snowflake IDs are commonly stored as strings to avoid JavaScript precision issues.Severity
Medium — index bypass and data consistency risk.
PR #88 opens the fix: #88
Two targeted changes:
app/db_engine.py—CharField(max_length=20)→BigIntegerFieldto match theBIGINTcolumn from the migrationapp/routers_v3/custom_commands.py— removedstr(discord_id)cast inget_creator_by_discord_id()that was working around the type mismatchNo migration needed — the DB column is already
BIGINT; only the ORM model was wrong.