Skip to content

fix(dev-scripts): use ncps migrate up in run.py - #1232

Merged
kalbasit merged 1 commit into
mainfrom
fix-dev-scripts-use-ncps-migrate
May 23, 2026
Merged

kalbasit merged 1 commit into
mainfrom
fix-dev-scripts-use-ncps-migrate

Conversation

@kalbasit

Copy link
Copy Markdown
Owner

The current branch's migrations live in migrations// in
goose format; run.py's dbmate up step was silently no-opping
because dbmate's default migrations dir is db/migrations/, which
no longer exists. Switch to go run . migrate up so the script
exercises the real embedded migration runner — and, against an
existing dbmate-shaped schema_migrations table, the dbmate→
goose adoption path in pkg/database/migrate/.

For non-sqlite backends, add a dbmate create step before the
migration. dbmate up used to auto-create the database; ncps migrate up only connects to an existing one. dbmate create
is no-op on first failure (database already exists) and errors
are suppressed, so the call is idempotent in practice. SQLite is
handled by ensuring the parent directory exists; the goose runner
creates the file on first connect.

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label May 22, 2026
This was referenced May 22, 2026
@kalbasit
kalbasit force-pushed the fix-dev-scripts-use-ncps-migrate branch from bd77619 to bb6d4d7 Compare May 23, 2026 04:22
@kalbasit
kalbasit force-pushed the chore-nix-restore-dbmate-to-the branch from 1ec29c3 to 1d95f60 Compare May 23, 2026 04:34
@kalbasit
kalbasit force-pushed the fix-dev-scripts-use-ncps-migrate branch from bb6d4d7 to 7c68609 Compare May 23, 2026 04:34
@kalbasit
kalbasit force-pushed the chore-nix-restore-dbmate-to-the branch from 1d95f60 to 30d8101 Compare May 23, 2026 04:47
@kalbasit
kalbasit force-pushed the fix-dev-scripts-use-ncps-migrate branch from 7c68609 to 01d7799 Compare May 23, 2026 04:47
@kalbasit
kalbasit force-pushed the chore-nix-restore-dbmate-to-the branch from 30d8101 to 941f4c9 Compare May 23, 2026 04:49
@kalbasit
kalbasit force-pushed the fix-dev-scripts-use-ncps-migrate branch from 01d7799 to 63c059d Compare May 23, 2026 04:49
@kalbasit
kalbasit force-pushed the chore-nix-restore-dbmate-to-the branch from 941f4c9 to 7257e05 Compare May 23, 2026 05:25
@kalbasit
kalbasit force-pushed the fix-dev-scripts-use-ncps-migrate branch from 63c059d to 4e7fa24 Compare May 23, 2026 05:25
@kalbasit
kalbasit force-pushed the chore-nix-restore-dbmate-to-the branch from 7257e05 to 8d9fae7 Compare May 23, 2026 05:29
@kalbasit
kalbasit force-pushed the fix-dev-scripts-use-ncps-migrate branch from 4e7fa24 to 574f4cf Compare May 23, 2026 05:29
@kalbasit
kalbasit force-pushed the chore-nix-restore-dbmate-to-the branch from 8d9fae7 to 22cbd69 Compare May 23, 2026 05:41
@kalbasit
kalbasit force-pushed the fix-dev-scripts-use-ncps-migrate branch from 574f4cf to 77f5f1e Compare May 23, 2026 05:41
@kalbasit
kalbasit force-pushed the chore-nix-restore-dbmate-to-the branch from 22cbd69 to 479faa2 Compare May 23, 2026 05:53
@kalbasit
kalbasit force-pushed the fix-dev-scripts-use-ncps-migrate branch from 77f5f1e to 0aaee14 Compare May 23, 2026 05:53
@kalbasit
kalbasit force-pushed the chore-nix-restore-dbmate-to-the branch from 479faa2 to b6a213b Compare May 23, 2026 06:06
@kalbasit
kalbasit force-pushed the fix-dev-scripts-use-ncps-migrate branch from 0aaee14 to efb1962 Compare May 23, 2026 06:06
@kalbasit

Copy link
Copy Markdown
Owner Author

Automated stack merge failed during the rebase step. The merge-stack label has been removed from all PRs in the stack. Please resolve conflicts locally, push, and re-apply the label on the top-most PR to retry. Run: https://github.com/kalbasit/ncps/actions/runs/26326665317

@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{"name":"HttpError","status":401,"request":{"method":"PATCH","url":"https://api.github.com/repos/kalbasit/ncps/issues/comments/4521545457","headers":{"accept":"application/vnd.github.v3+json","user-agent":"octokit.js/0.0.0-development octokit-core.js/7.0.6 Node.js/24","authorization":"token [REDACTED]","content-type":"application/json; charset=utf-8"},"body":{"body":"<!-- This is an auto-generated comment: summarize by coderabbit.ai -->\n<!-- This is an auto-generated comment: failure by coderabbit.ai -->\n\n> [!CAUTION]\n> ## Review failed\n> \n> An error occurred during the review process. Please try again later.\n\n<!-- end of auto-generated comment: failure by coderabbit.ai -->\n\n<!-- tips_start -->\n\n---\n\n\n\n\n<sub>Comment `@coderabbitai help` to get the list of available commands and usage tips.</sub>\n\n<!-- tips_end -->"},"request":{"retryCount":1,"signal":{}}},"response":{"url":"https://api.github.com/repos/kalbasit/ncps/issues/comments/4521545457","status":401,"headers":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","connection":"close","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Sat, 23 May 2026 16:53:53 GMT","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"github.com","strict-transport-security":"max-age=31536000; includeSubdomains; preload","vary":"Accept-Encoding, Accept, X-Requested-With","x-content-type-options":"nosniff","x-frame-options":"deny","x-github-media-type":"github.v3; format=json","x-github-request-id":"041F:31D750:BB5886B:2D00B560:6A11DBA1","x-xss-protection":"0"},"data":{"message":"Bad credentials","documentation_url":"https://docs.github.com/rest","status":"401"}}}

The current branch's migrations live in migrations/<dialect>/ in
goose format; run.py's `dbmate up` step was silently no-opping
because dbmate's default migrations dir is db/migrations/, which
no longer exists. Switch to `go run . migrate up` so the script
exercises the real embedded migration runner — and, against an
existing dbmate-shaped `schema_migrations` table, the dbmate→
goose adoption path in pkg/database/migrate/.

For non-sqlite backends, add a `dbmate create` step before the
migration. `dbmate up` used to auto-create the database; `ncps
migrate up` only connects to an existing one. `dbmate create`
is no-op on first failure (database already exists) and errors
are suppressed, so the call is idempotent in practice. SQLite is
handled by ensuring the parent directory exists; the goose runner
creates the file on first connect.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@dev-scripts/run.py`:
- Around line 371-377: The call to subprocess.run(["dbmate", ...]) can raise
FileNotFoundError if dbmate isn't installed; add a pre-check using
shutil.which("dbmate") (like the check in perform_clean) before calling
subprocess.run in the branch that uses db_url, and if not found raise a clear
RuntimeError or print an explanatory message mentioning dbmate is missing and
instructing how to install it; keep the existing subprocess.run parameters
(check=False, stdout/stderr DEVNULL) but only execute them after the
shutil.which check.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a65329cd-c7ad-4d34-af78-f7a4f749f39a

📥 Commits

Reviewing files that changed from the base of the PR and between 998d526 and 4327e65.

📒 Files selected for processing (1)
  • dev-scripts/run.py

Comment thread dev-scripts/run.py Resolved
@codecov

codecov Bot commented May 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 5.50%. Comparing base (998d526) to head (4327e65).

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1232   +/-   ##
=====================================
  Coverage   5.50%   5.50%           
=====================================
  Files          6       6           
  Lines        400     400           
=====================================
  Hits          22      22           
  Misses       374     374           
  Partials       4       4           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-stack size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant