refactor(store): enforce NOT NULL on nullable text columns - #13
Merged
0dillon merged 1 commit intoAug 14, 2026
Merged
Conversation
Make challenges.client_domain, sessions.memo, and sessions.client_domain NOT NULL DEFAULT '', storing the absence of a value as an empty string rather than NULL. Adds a golang-migrate migration that backfills existing NULLs before tightening the columns, and updates the store to insert and read strings directly instead of through a nullable helper. Closes 0dillon#3
ogundeleoluwaferanmi35
force-pushed
the
enforce-not-null-text-columns
branch
from
August 14, 2026 01:20
d1b4fe7 to
5174a3b
Compare
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.
Summary
Three TEXT columns in the PostgreSQL schema were nullable:
challenges.client_domainsessions.memosessions.client_domainFor consistency and stricter data integrity they now use
NOT NULL DEFAULT '', so the absence of a value is stored as an empty string rather thanNULL.Changes
000002_not_null_text_columnsthat backfills existingNULLvalues with''before settingDEFAULT ''andNOT NULLon each column, plus a matching down migration.internal/store/postgres.goto insert empty strings directly (removed thenullablehelper) and to scanclient_domainstraight into a string instead of through a*string.TestMigrationsAreEmbeddedto expect the new migration files and assert theSET NOT NULLalters are present.Verification
gofmt,go vet,go build, andgo test ./...pass.go test -tags postgres_integration ./internal/store/.information_schemathat all three columns areNOT NULLwith default'', and the down migration applies cleanly.Closes #3