Skip to content

feat: v0.2.0 — Atlas driver, lint tool, atlas plugin binary, Dockerfile#2

Merged
intel352 merged 6 commits into
mainfrom
feat/task-27-31b
Apr 23, 2026
Merged

feat: v0.2.0 — Atlas driver, lint tool, atlas plugin binary, Dockerfile#2
intel352 merged 6 commits into
mainfrom
feat/task-27-31b

Conversation

@intel352
Copy link
Copy Markdown
Contributor

Summary

  • Task 27: Atlas migration driver (internal/atlas) backed by ariga.io/atlas v1.2.0 — full Up/Down/Status/Goto with SQL-backed RevisionReadWriter (atlas_schema_revisions table); auto-generates atlas.sum when absent so Atlas CLI is not required
  • Task 28: Static lint tool (pkg/lint) — checks L001 ordering gaps, L002 duplicates, L003 naming convention, L004 dangerous ops, L005 missing .down.sql, L006 empty files; migrate lint <dir> [--json] CLI subcommand
  • Task 27 cont: Wire internal/atlasplugin — replace stub with real CreateModule dispatcher supporting all three drivers; driverBackedModule stubs for golang-migrate/goose explain intentional non-implementation
  • Task 29: cmd/workflow-migrate/Dockerfile — two-stage distroless/static OCI image with ARG TARGETARCH for multi-platform buildx support
  • Task 30: pkg/cli/root.go adds lint subcommand + atlas driver case; plugin.json updated with lint in cliCommands and atlas in keywords

Test plan

  • CI green (integration tests run against postgres service container)
  • go build ./... clean
  • go vet ./... clean
  • go test ./... -short -count=1 -race passes all packages including internal/atlas and pkg/lint
  • Copilot review addressed

🤖 Generated with Claude Code

intel352 and others added 6 commits April 22, 2026 21:40
Task 27: Atlas driver (ariga.io/atlas v1.2.0)
- internal/atlas/driver.go: full MigrationDriver implementation (Up/Down/Status/Goto)
- internal/atlas/revisions.go: SQL-backed RevisionReadWriter (atlas_schema_revisions table)
- internal/atlas/driver_test.go: Name + UpDownStatus integration tests
- Auto-generates atlas.sum when absent so Atlas CLI is not required for basic ops
- Down reads paired <version>.down.sql files for rollback SQL

Task 28: Lint tool
- pkg/lint/lint.go: static analysis (L001 ordering gap, L002 duplicate, L003 naming,
  L004 dangerous ops, L005 missing .down.sql, L006 empty file)
- pkg/lint/lint_test.go: one test per lint code
- pkg/cli/lint.go: `migrate lint <dir>` cobra subcommand with --json output

Task 27 (cont): Atlas plugin binary wiring
- internal/atlasplugin/plugin.go: replace stub with real CreateModule dispatcher
- internal/atlasplugin/modules.go: atlasMigrationsModule, driverModule, driverBackedModule

Task 29: workflow-migrate standalone binary
- cmd/workflow-migrate/Dockerfile: distroless/static OCI image for pre-deploy jobs

Task 30: wfctl CLI update
- pkg/cli/root.go: add lint subcommand + atlas driver support
- plugin.json: update description, keywords, migrationDrivers, cliCommands

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- gofmt: fix import ordering in driver_test.go (workflow-plugin-migrations before workflow)
- gofmt: fix over-aligned stubs in atlasplugin/modules.go
- atlas/driver.go: replace 1MB fixed read buffer with io.ReadAll in runDown
- Dockerfile: use ARG TARGETARCH + GOARCH=$TARGETARCH for multi-platform buildx support
- atlasplugin/modules.go: add clarifying comment explaining driverBackedModule.InvokeMethod
  is intentionally unimplemented (use workflow-plugin-migrations binary for those drivers)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
gofmt requires a blank line between the Stop stub and the doc comment
on driverBackedModule.InvokeMethod.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The testharness creates an isolated schema (wfm_test_*) that Atlas sees
as a non-clean database state, causing the executor to refuse to run.
WithAllowDirty(true) tells Atlas to proceed regardless of existing
schemas in the database — correct for tests and for users running
migrations against non-empty Postgres instances.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Atlas scans all *.sql files in the migration directory. Placing
.down.sql files in the same directory as up migrations causes duplicate
version numbers (e.g. both 00001_create_users.sql and
00001_create_users.down.sql have version 00001). When Atlas processes
the second file for an already-seen version it reads the stored revision
(Applied=1) and tries to validate PartialHashes[0], which is nil in our
implementation — causing a panic at migrate.go:855.

Fix: require down files to live in <dir>/down/<name>.down.sql. Update
runDown() to check the preferred path first, with a legacy fallback to
the flat layout. Update makeAtlasDir() in tests to write down files to
the new subdirectory. Drop the now-unused "io" import.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
pkg/conformance/runner.go — CLI-friendly Runner (no *testing.T) with
Setup() for --keep-alive and Run() for full-cycle + checkpoint cases.

pkg/cli/test.go — `migrate test` cobra command: drives the conformance
Runner against a user-supplied DSN + source-dir. --keep-alive applies
all migrations and prints DSN for integration test setup.

pkg/cli/tenant_ensure.go — `migrate tenant-ensure` cobra command:
CREATE SCHEMA IF NOT EXISTS via pgx, idempotent pre-deploy step for
multi-tenant environments.

pkg/cli/root.go — register both new commands in NewRoot().

plugin.json — add test + tenant-ensure to cliCommands subcommands.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@intel352 intel352 merged commit 3c9581a into main Apr 23, 2026
3 checks passed
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.

1 participant