Repository navigation
feat: add rowx check --scratch - #163
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c8410ce644
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…pelling Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes #148
What
rowx check --scratchbuilds a throwaway database from the migrations, checks against it, and drops it.rowx_check_<16 hex>withTEMPLATE template0, runsMigrator.runon a normal writable connection (closed before the checker session opens), then runs the usual read-only check session on that database.--scratch.--scratchwithout[tool.rowx.migrate]exits 2. The migration files are read before any database is created, so a broken directory fails first.WITH (FORCE)on every exit path: success, diagnostics, migration failure, describe failure, internal error,KeyboardInterruptand real SIGINT. The drop runs in the async context manager'sfinally. If it was interrupted (a second Ctrl-C),Scratch.sweep()retries it once from outside the event loop. A drop that still fails prints awarning:line to stderr and never masks the original error.--scratchneeds a role with CREATEDB". A failing migration exits 2 and names the version and the server error.rowx.postgres._admin.with_database(dsn, name), shared sorowx.testing(feat: add rowx.testing pytest plugin #149) can reuse it. The driver percent-decodes query keys and applies them after the path, last one winning, so every spelling ofdbname(including%64bname) is dropped, the new name is appended last withurlencode(..., quote_via=quote), and the result is parsed back withConnectOptions.from_dsnand rejected unless it names the scratch database. Before this,?%64bname=<db>made--scratchrun the migrations on<db>.[tool.rowx.migrate](dir,table,create_schemas) throughload_migrator, asrowx migrate rundoes.--statisticsaddsscratch database built in: N.NNs(create plus migrate).--helpfor--scratchand indocs/guide.md.New tests
Integration (
src/rowx/__tests__/integration/check/test_check_cli.py,db). Theno_leftoversfixture comparespg_databasebefore and after each test and fails on any leakedrowx_check_*:test_scratch_clean_run_when_the_target_lacks_the_tables(the drift gate rejects the same database)test_scratch_reports_diagnostics_against_the_scratch_schematest_scratch_never_touches_the_target_databasetest_scratch_failing_migration_exits_twotest_scratch_without_createdb_exits_two_with_helptest_scratch_without_migrate_config_is_a_usage_errortest_scratch_unreachable_server_never_prints_the_passwordtest_scratch_statistics_report_the_build_timetest_scratch_is_not_built_when_nothing_is_describedtest_scratch_is_dropped_when_the_check_is_interrupted_or_fails, parametrized overKeyboardInterrupt, a real SIGINT throughasyncio.run, an internal error and a describe failuretest_scratch_check_session_is_read_onlytest_scratch_honours_the_migrate_table_and_create_schemas(history inrowx_meta.history, tables in acreate_schemasschema)test_scratch_never_migrates_a_database_named_in_the_query_string(?%64bname=<target>; fails on the first version of this PR)Unit (
src/rowx/__tests__/unit/check/test_scratch.py):test_scratch_names_fit_the_identifier_limittest_scratch_url_that_cannot_be_parsed_never_quotes_the_dsnUnit (
src/rowx/__tests__/unit/postgres/test__admin.py):test_with_database(URL, key=value, multi-host,dbnamequery parameter)test_with_database_overrides_every_dbname(%64bname, fully encoded keys, repeated keys, no path, key=value)test_with_database_keeps_everything_elsetest_with_database_quotes_the_nameWiring edits
src/rowx/check/scratch.py.src/rowx/postgres/_admin.py: addswith_database(private module, not exported).src/rowx/check/runner.py:run_checktakes aHooks(gate, scratch)dataclass instead of thegatekeyword (clippy-styletoo-many-arguments).Statistics.scratch_secondsandScratchBuildare added.src/rowx/check/cli.py:--scratchflag,_check(args), and the statistics line.docs/guide.md: usage line and the amended safety statement.docs/designis untouched.Spec ambiguities
--scratchon a tree without queries doesn't validate the migrations (and needs no URL). Kept deliberately: a run with nothing to describe never needs a database, androwx database setup/rowx migrate runvalidate migrations. Building it anyway is a one-line change if the design prefers.create_databaseconnects to the maintenance database (postgres, ortemplate1) asrowx databasedoes.--scratchuses the configureddir,tableandcreate_schemas, and themigrate rundefaults for the flags (no out-of-order and no ignore-missing), since the database is empty.🤖 Generated with Claude Code