Skip to content

MSSQL testdb: podman CLI engine, container user, schema hook, snapshot reset - #65

Closed
aersam wants to merge 6 commits into
mainfrom
issue-64-mssql-testdb
Closed

aersam wants to merge 6 commits into
mainfrom
issue-64-mssql-testdb

Conversation

@aersam

@aersam aersam commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #64

What changed

1. Container engine (blocking item in #64)

  • _docker.client() falls back to the podman/docker CLI when no API socket is reachable (rootless Podman without a systemd user session). PGDEVKIT_CONTAINER_ENGINE=docker|podman forces the CLI; unset/auto tries the SDK first. Applies to the Postgres and the MSSQL container. Secrets are passed via the child environment, not argv.
  • PGDEVKIT_TESTDB_MSSQL_CONTAINER_USER is passed as user= / --user.
  • README documents the rootless Podman recipe.

2. Generated schema + fast reset (blocking item in #64)

  • ensure_testdb(..., apply=callable(conn), apply_scripts=True) (also reset_testdb): MSSQL-only schema-provider hook, after or instead of the database/ files.
  • snapshot_testdb(name="template") / restore_testdb(name="template"): SQL Server database snapshots. Snapshot files go next to the data files (so they follow a tmpfs mount) or into PGDEVKIT_TESTDB_MSSQL_SNAPSHOT_DIR. Snapshots are dropped with their database and never reported as orphans. A restore needs the sole snapshot of the database, so it raises instead of dropping others.

3. NAV-style names (verification in #64) — real bugs found and fixed

  • database/ files with names like [Company$Cust_ Ledg_ Entry é] were applied in the wrong order (views before tables): dependency names came out re-quoted and never matched the file-derived names.
  • compare: decimal(38,20) vs numeric(38, 20) and bracket-quoted index columns / names with spaces gave false diffs; a nested-paren filter (([b]>(1))) too.
  • Measured on a real SQL Server 2022 (rootless Podman) with 1,950 tables and 4,500 views: apply 17 s, parse 2.3 s, introspect 6.4 s, diff 0.4 s, 98 MB peak RSS, 0 diffs. Introspection issues several queries per table, so against a remote server it is latency-bound; not changed here.
  • Views are introspected and compared; update-stats quotes names correctly.

4. Per-worktree names (verification in #64)

  • Worktrees nested under <repo>/.claude/worktrees/<id> are found. A locked worktree whose path is missing was treated as not live (its database would be dropped by clean_testdb(orphaned=True)); it now counts as live.

Tests

New unit tests (CLI adapter, engine selection, naming, dependency ordering, diff normalization) and live MSSQL tests (hook, snapshot/restore round trip incl. open connection, orphan handling, NAV-style compare and stats). Full suite run locally against SQL Server 2022 under rootless Podman: 564 passed (the Postgres-container tests in test_container.py need a registry config this sandbox lacks).

🤖 Generated with Claude Code

@aersam

aersam commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Split into one PR per topic: #66 (container CLI engine + user), #67 (apply hook + snapshots), #68 (NAV-style names), #69 (locked worktrees).

@aersam aersam closed this Oct 31, 2026
aersam and others added 6 commits October 31, 2026 07:46
…is reachable; add MSSQL container user (#64)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…64)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…n; treat locked worktrees as live; bump to 0.18.0 (#64)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MSSQL testdb: rootless podman/CLI engine, generated-schema hook, snapshot reset, NAV-style object names

1 participant