schema(scanner): add scan_country to scan_history (#921)#933
Merged
ericsocrat merged 1 commit intomainfrom Mar 17, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds country context to the scanner’s persisted history by extending scan_history with a nullable, FK-backed scan_country column. This supports the broader “country-aware scanner” epic by enabling country-scoped analytics and downstream routing decisions without changing API behavior yet.
Changes:
- Add
scan_history.scan_country(nullable) with FK tocountry_ref(country_code). - Add a partial index on
scan_history(scan_country)for non-NULL rows to support country-scoped queries. - Extend pgTAP schema contract tests to assert the new column, nullability, and FK; update plan count.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
supabase/migrations/20260320000100_scan_history_country.sql |
Adds nullable scan_country with FK + partial index for analytics queries. |
supabase/tests/schema_contracts.test.sql |
Adds pgTAP assertions for the new column/FK and updates the test plan. |
Comment on lines
+424
to
+429
| -- ─── scan_history.scan_country (#921, epic #920) ───────────────────────────── | ||
| SELECT has_column('public', 'scan_history', 'scan_country', 'scan_history has scan_country column'); | ||
| SELECT col_is_null('public', 'scan_history', 'scan_country', 'scan_history.scan_country is nullable'); | ||
| SELECT fk_ok('public', 'scan_history', 'scan_country', | ||
| 'public', 'country_ref', 'country_code', | ||
| 'scan_history.scan_country references country_ref(country_code)'); |
This was referenced Mar 17, 2026
This was referenced Mar 17, 2026
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
Adds a nullable
scan_countrycolumn toscan_historywith FK tocountry_ref(country_code). This captures the user's catalog region at scan time, enabling downstream country-aware scanner features.Part of epic #920. Closes #921.
Changes
Migration:
20260320000100_scan_history_country.sqlALTER TABLE scan_history ADD COLUMN IF NOT EXISTS scan_country text REFERENCES country_ref(country_code)— nullable for backward compatidx_sh_countryonscan_country WHERE scan_country IS NOT NULL— for country-scoped analyticspgTAP:
schema_contracts.test.sqlhas_column,col_is_null,fk_okforscan_history.scan_countryFiles Changed
supabase/migrations/20260320000100_scan_history_country.sqlsupabase/tests/schema_contracts.test.sql2 files changed, +26 / -1 lines
Acceptance Criteria
scan_historyhasscan_country text REFERENCES country_ref(country_code)columnidx_sh_countryexists onscan_country WHERE NOT NULLhas_column('scan_history', 'scan_country')passesADD COLUMN IF NOT EXISTS)supabase db resetsucceeds cleanly.\RUN_QA.ps1— no new failures introducedVerification
Column verification
Wording Corrections
Issue #921 body says
WHERE NOT NULLin the acceptance criteria butWHERE scan_country IS NOT NULLin the SQL block. The migration uses the technically correctWHERE scan_country IS NOT NULLsyntax (standard SQL).Scope
This PR adds only the schema column — no API changes, no frontend changes, no data backfill. Those are handled by downstream issues in the #920 epic.
Next Issue
Recommend: #922 —
schema(scanner): add scan_country + suggested_country to product_submissions