Repository navigation
feat(dir): add scan source - #2426
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
csirmazbendeguz
marked this pull request as ready for review
October 28, 2026 10:54
csirmazbendeguz
force-pushed
the
feat/scan-source
branch
from
October 28, 2026 10:55
4fab314 to
0415755
Compare
ramizpolic
previously approved these changes
Oct 28, 2026
tkircsi
reviewed
Oct 28, 2026
Comment on lines
+50
to
+57
| // ADD COLUMN with a constant DEFAULT fills existing rows on both SQLite and | ||
| // PostgreSQL. This covers a backend that left them NULL instead. | ||
| err := db.Model(&scanReportSourceRow{}). | ||
| Where("source IS NULL"). | ||
| Update("source", "").Error | ||
| if err != nil { | ||
| return fmt.Errorf("backfill scan_reports source: %w", err) | ||
| } |
Contributor
There was a problem hiding this comment.
The backfill is unreachable. scanReportSourceRow.Source is tagged not null;default:'', so AddColumn emits `source` text NOT NULL DEFAULT "" (confirmed against the generated SQLite DDL; PostgreSQL is the same shape). source IS NULL can therefore never match, and the comment above it — "this covers a backend that left them NULL instead" — describes a case the NOT NULL makes impossible.
Worth settling now rather than later, since a migration is immutable once merged and a follow-up could only add a 007 that fixes nothing.
Two ways out:
- Drop the
Updateand keep thenot null;default:''tag. TheADD COLUMNdefault already fills existing rows with'', which is what we want them to read as. - Follow 004: declare the column nullable here, keep the backfill, and let AutoMigrate apply
NOT NULLafterwards.scan_test.go:420calls that ordering load-bearing for PostgreSQL, so matching it keeps one pattern across the migrations.
Signed-off-by: Bendegúz Csirmaz <[email protected]>
csirmazbendeguz
force-pushed
the
feat/scan-source
branch
from
October 28, 2026 11:54
0415755 to
f4960e7
Compare
2 tasks done
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.
refs #2342
this PR adds scan sources. it stores the source (local/imported) in the database table. and passes it to the policies for validation