Repository navigation
Add a foreign key from officials to users - #215
Merged
Merged
Conversation
russellporter
force-pushed
the
t3/officials-foreign-key
branch
from
November 30, 2026 19:15
60119f7 to
b4f6025
Compare
Nothing stopped officials pointing at a deleted user, which broke the officials page. Deleting a user who still has officials now fails. The migration lists any officials without a user and stops, since they may be real certifications. With the constraint in place, the page no longer needs its missing user fallback.
russellporter
force-pushed
the
t3/officials-foreign-key
branch
from
November 30, 2026 22:25
b4f6025 to
56540a9
Compare
russellporter
marked this pull request as ready for review
November 30, 2026 22:25
russellporter
marked this pull request as draft
November 30, 2026 22:31
Production's officials table is MyISAM, so MariaDB accepted the foreign key without creating it. Its user_id is also signed, but users.id is unsigned.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#213 is deployed, and the only orphaned official in production has been removed. The migration fails if there are any, which stops
deploy.sh(including the weekly deploy) after it has started the new containers. Just before merging, check that this still returns an empty list in the production console:officialsto InnoDB and giveuser_idthe same type asusers.id. In production,officialsuses MyISAM and itsuser_idis signed, butusers.idis unsigned.schema.rbdoesn't show either difference, so CI can't catch them. On MyISAM, MariaDB accepts the foreign key without creating it, so the migration would appear to succeed.Rolling back removes the foreign key, but leaves the table on InnoDB with the new column type.
Testing
schema.rb.