Repository navigation
refactor(testhelper): switch to migrate.Up for schema setup - #1197
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
9d66305 to
394ceb3
Compare
7476f56 to
d47e51b
Compare
394ceb3 to
c261c89
Compare
d47e51b to
6caee71
Compare
c261c89 to
faa691a
Compare
6caee71 to
b63df34
Compare
faa691a to
82320c8
Compare
b63df34 to
7eb0409
Compare
82320c8 to
ed01afa
Compare
7eb0409 to
69fd9fc
Compare
ed01afa to
aa2db41
Compare
69fd9fc to
756cb1b
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThree test helper functions are refactored to run embedded migrations in-process via migrate.Up: MySQL, PostgreSQL, and SQLite helpers now open connections, select dialect-specific migrations from migrations.FS, and execute migrations without spawning external processes. ChangesDatabase test helper migration refactoring
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
aa2db41 to
dcf22dc
Compare
7f0de59 to
d963c81
Compare
Replace the dbmate exec.Command invocations in CreateMigrateDatabase / MigratePostgresDatabase / MigrateMySQLDatabase with the same pkg/database/migrate.Up flow `ncps migrate up` uses in production: empty DB → ent.Schema.Create → final schema. Three motivations: 1. The dbmate-only path produces a schema without the §10b surrogate `id` columns on weak entities (narinfo_references, narinfo_signatures, narinfo_nar_files, nar_file_chunks). Ent's edge traversals (WithReferences / WithSignatures / WithNarInfoNarFiles) generate SQL that selects those columns; tests against the dbmate schema fail with "no such column: narinfo_references.id". Blocked §11.2's cascading conversions in pkg/cache. Now unblocked. 2. Eliminates the external dbmate binary dependency from the test path. Tests now exercise the production migrate code on every run, so schema-bug regressions surface in unit tests instead of integration. 3. Drops the need for `runtime.Caller`-derived `db/migrations/<dialect>/` path lookups. The migrations are loaded from `migrations/` via the embedded `migrations.FS`, the same source of truth ncps ships in its binary. Required prerequisite: the previous commit's Ent schema fix for `last_accessed_at DEFAULT CURRENT_TIMESTAMP`. Without it, contract tests that read `LastAccessedAt.Time` would see NULL instead of the expected insert-time timestamp. Full -race test suite passes against SQLite + Postgres + MySQL with the deps stack running. Lint clean.
d963c81 to
196e69e
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1197 +/- ##
========================================
- Coverage 6.26% 5.68% -0.59%
========================================
Files 6 6
Lines 335 387 +52
========================================
+ Hits 21 22 +1
- Misses 310 361 +51
Partials 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Replace the dbmate exec.Command invocations in
CreateMigrateDatabase / MigratePostgresDatabase /
MigrateMySQLDatabase with the same pkg/database/migrate.Up
flow
ncps migrate upuses in production: empty DB →ent.Schema.Create → final schema. Three motivations:
The dbmate-only path produces a schema without the §10b
surrogate
idcolumns on weak entities(narinfo_references, narinfo_signatures,
narinfo_nar_files, nar_file_chunks). Ent's edge traversals
(WithReferences / WithSignatures /
WithNarInfoNarFiles) generate SQL that selects those
columns; tests against the dbmate schema fail with
"no such column: narinfo_references.id". Blocked
§11.2's cascading conversions in pkg/cache. Now unblocked.
Eliminates the external dbmate binary dependency from
the test path. Tests now exercise the production migrate
code on every run, so schema-bug regressions surface in
unit tests instead of integration.
Drops the need for
runtime.Caller-deriveddb/migrations/<dialect>/path lookups. The migrationsare loaded from
migrations/via the embeddedmigrations.FS, the same source of truth ncps ships inits binary.
Required prerequisite: the previous commit's Ent schema fix
for
last_accessed_at DEFAULT CURRENT_TIMESTAMP. Without it,contract tests that read
LastAccessedAt.Timewould seeNULL instead of the expected insert-time timestamp.
Full -race test suite passes against SQLite + Postgres +
MySQL with the deps stack running. Lint clean.