Repository navigation
docs(claude): rewrite CLAUDE.md for the Ent + Atlas + Goose workflow - #1224
Conversation
|
Related Knowledge 1 document with suggested updates is ready for review. kalbasit's Space Development Environment with MinIOView Suggested Changes@@ -38,23 +38,31 @@
[See initialization script](https://github.com/kalbasit/ncps/blob/cf8e19f/nix/process-compose/init-minio.sh)
# Database Migration Transaction Handling
-**IMPORTANT:** Do NOT manually add `BEGIN`/`COMMIT` blocks to your migration files. The `dbmate` tool automatically wraps each migration in a transaction for atomicity. Adding manual transaction blocks will cause errors such as "cannot start a transaction within a transaction."
+**IMPORTANT:** Do NOT manually add `BEGIN`/`COMMIT` blocks to your migration files. Goose automatically wraps each migration in a transaction for atomicity. Adding manual transaction blocks will cause errors such as "cannot start a transaction within a transaction."
+
+Migrations that need to disable automatic transaction wrapping must add the `-- +goose NO TRANSACTION` directive at the top of the file (immediately below the `-- +goose Up` marker). This is specifically needed for SQLite migrations that require `PRAGMA foreign_keys = OFF`.
**Example:**
```sql
-- ❌ WRONG - Don't add manual transactions
--- migrate:up
+-- +goose Up
BEGIN;
CREATE TABLE example (...);
COMMIT;
--- ✅ CORRECT - Let dbmate handle transactions
--- migrate:up
+-- ✅ CORRECT - Let Goose handle transactions
+-- +goose Up
CREATE TABLE example (...);
+
+-- ✅ CORRECT - Disable transactions when needed (e.g., for SQLite PRAGMA)
+-- +goose Up
+-- +goose NO TRANSACTION
+PRAGMA foreign_keys = OFF;
+-- Migration statements here
```
-Letting dbmate manage transactions ensures that if any part of a migration fails, the entire migration is rolled back, preventing partial or inconsistent database states.
+Letting Goose manage transactions ensures that if any part of a migration fails, the entire migration is rolled back, preventing partial or inconsistent database states.
## Running MinIO and Initialization
Start MinIO and run the initialization process using: |
…e down - Bring the Common Commands DSN examples in line with the Database section by using the full host:port/database placeholder for postgresql/mysql. - Replace "there is no migrate down command" with the accurate phrasing: the command is implemented (pkg/ncps/migrate.go:107) but returns an error pointing at the expand-contract policy. Addresses gemini-code-assist comments on PR #1224 (PRRT_kwDONV6tZs6D37b-, PRRT_kwDONV6tZs6D37cD). The third sqlfluff suggestion is intentionally skipped — migrations/ is sealed by atlas.sum so sqlfluff isn't run against it, and the only SQL outside migrations/ is already covered by nix fmt. Co-Authored-By: Claude Opus 4.7 <[email protected]>
90e681a to
a7a9235
Compare
0711dc7 to
88834a7
Compare
…e down - Bring the Common Commands DSN examples in line with the Database section by using the full host:port/database placeholder for postgresql/mysql. - Replace "there is no migrate down command" with the accurate phrasing: the command is implemented (pkg/ncps/migrate.go:107) but returns an error pointing at the expand-contract policy. Addresses gemini-code-assist comments on PR #1224 (PRRT_kwDONV6tZs6D37b-, PRRT_kwDONV6tZs6D37cD). The third sqlfluff suggestion is intentionally skipped — migrations/ is sealed by atlas.sum so sqlfluff isn't run against it, and the only SQL outside migrations/ is already covered by nix fmt. Co-Authored-By: Claude Opus 4.7 <[email protected]>
a7a9235 to
5509f29
Compare
88834a7 to
e392a8d
Compare
…e down - Bring the Common Commands DSN examples in line with the Database section by using the full host:port/database placeholder for postgresql/mysql. - Replace "there is no migrate down command" with the accurate phrasing: the command is implemented (pkg/ncps/migrate.go:107) but returns an error pointing at the expand-contract policy. Addresses gemini-code-assist comments on PR #1224 (PRRT_kwDONV6tZs6D37b-, PRRT_kwDONV6tZs6D37cD). The third sqlfluff suggestion is intentionally skipped — migrations/ is sealed by atlas.sum so sqlfluff isn't run against it, and the only SQL outside migrations/ is already covered by nix fmt. Co-Authored-By: Claude Opus 4.7 <[email protected]>
5509f29 to
27ac0ea
Compare
e392a8d to
490804f
Compare
…e down - Bring the Common Commands DSN examples in line with the Database section by using the full host:port/database placeholder for postgresql/mysql. - Replace "there is no migrate down command" with the accurate phrasing: the command is implemented (pkg/ncps/migrate.go:107) but returns an error pointing at the expand-contract policy. Addresses gemini-code-assist comments on PR #1224 (PRRT_kwDONV6tZs6D37b-, PRRT_kwDONV6tZs6D37cD). The third sqlfluff suggestion is intentionally skipped — migrations/ is sealed by atlas.sum so sqlfluff isn't run against it, and the only SQL outside migrations/ is already covered by nix fmt. Co-Authored-By: Claude Opus 4.7 <[email protected]>
27ac0ea to
2551daa
Compare
490804f to
1c0dbae
Compare
…e down - Bring the Common Commands DSN examples in line with the Database section by using the full host:port/database placeholder for postgresql/mysql. - Replace "there is no migrate down command" with the accurate phrasing: the command is implemented (pkg/ncps/migrate.go:107) but returns an error pointing at the expand-contract policy. Addresses gemini-code-assist comments on PR #1224 (PRRT_kwDONV6tZs6D37b-, PRRT_kwDONV6tZs6D37cD). The third sqlfluff suggestion is intentionally skipped — migrations/ is sealed by atlas.sum so sqlfluff isn't run against it, and the only SQL outside migrations/ is already covered by nix fmt. Co-Authored-By: Claude Opus 4.7 <[email protected]>
2551daa to
3750cae
Compare
1c0dbae to
1681faf
Compare
…e down - Bring the Common Commands DSN examples in line with the Database section by using the full host:port/database placeholder for postgresql/mysql. - Replace "there is no migrate down command" with the accurate phrasing: the command is implemented (pkg/ncps/migrate.go:107) but returns an error pointing at the expand-contract policy. Addresses gemini-code-assist comments on PR #1224 (PRRT_kwDONV6tZs6D37b-, PRRT_kwDONV6tZs6D37cD). The third sqlfluff suggestion is intentionally skipped — migrations/ is sealed by atlas.sum so sqlfluff isn't run against it, and the only SQL outside migrations/ is already covered by nix fmt. Co-Authored-By: Claude Opus 4.7 <[email protected]>
3750cae to
d3ecada
Compare
1681faf to
999a958
Compare
…e down - Bring the Common Commands DSN examples in line with the Database section by using the full host:port/database placeholder for postgresql/mysql. - Replace "there is no migrate down command" with the accurate phrasing: the command is implemented (pkg/ncps/migrate.go:107) but returns an error pointing at the expand-contract policy. Addresses gemini-code-assist comments on PR #1224 (PRRT_kwDONV6tZs6D37b-, PRRT_kwDONV6tZs6D37cD). The third sqlfluff suggestion is intentionally skipped — migrations/ is sealed by atlas.sum so sqlfluff isn't run against it, and the only SQL outside migrations/ is already covered by nix fmt. Co-Authored-By: Claude Opus 4.7 <[email protected]>
d3ecada to
16b7c11
Compare
999a958 to
55c9051
Compare
…e down - Bring the Common Commands DSN examples in line with the Database section by using the full host:port/database placeholder for postgresql/mysql. - Replace "there is no migrate down command" with the accurate phrasing: the command is implemented (pkg/ncps/migrate.go:107) but returns an error pointing at the expand-contract policy. Addresses gemini-code-assist comments on PR #1224 (PRRT_kwDONV6tZs6D37b-, PRRT_kwDONV6tZs6D37cD). The third sqlfluff suggestion is intentionally skipped — migrations/ is sealed by atlas.sum so sqlfluff isn't run against it, and the only SQL outside migrations/ is already covered by nix fmt. Co-Authored-By: Claude Opus 4.7 <[email protected]>
16b7c11 to
eaa8115
Compare
55c9051 to
1783d26
Compare
|
Automated stack merge failed during the rebase step. The |
There was a problem hiding this comment.
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 `@CLAUDE.md`:
- Around line 42-43: Update the README headings and text that currently claim
"Lint Ent schemas + generated baseline migrations for codegen invariants" (and
the corresponding sections around lines referenced) to precisely state that
cmd/ent-lint only enforces migration-baseline checks and the A1, A2, and A4
invariants today; make the same change in the other occurrences (the sections
around line 169 and the larger section around 730–747) so all headings and
descriptive sentences consistently say "enforces migration-baseline and A1/A2/A4
invariants" rather than implying full A1–A5 coverage.
🪄 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: 1cc4e70c-3bee-412b-80d3-0979883daa12
📒 Files selected for processing (2)
CLAUDE.mdopenspec/changes/migrate-to-ent-and-atlas/tasks.md
Replaces every reference to the removed sqlc / dbmate /
dbmate-wrapper / db/query.*.sql / db/schema/ / db/migrations/ tooling
with the Ent + Atlas + Goose workflow:
- New "Common Commands" section covers `go generate ./ent/...`,
`go run ./cmd/ent-lint`, `task ent:check`,
`go run ./cmd/generate-migrations` (schema-driven + --sql-only),
`ncps migrate up` (with --dry-run), and `go run ./cmd/atlas-sum-check`.
- "Skills" block lists the new ent-schema / migrate-new / migrate-up /
migrate-down skills.
- "Package Structure" reorganized around `cmd/{ent-lint,generate-migrations,atlas-sum-check}`,
`ent/schema/` (hand-authored) vs `ent/` (committed codegen), and
`migrations/<dialect>/` with embedded `atlas.sum` integrity files.
- New "Database" section documents the expand-contract policy (column
changes split across N migrations), the four-step NOT NULL recipe,
and the five Ent codegen invariants (A1-A5) enforced by
`cmd/ent-lint`.
Marks task 14.1 complete in the migrate-to-ent-and-atlas change.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1224 +/- ##
=====================================
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. 🚀 New features to boost your workflow:
|
Replaces every reference to the removed sqlc / dbmate /
dbmate-wrapper / db/query.*.sql / db/schema/ / db/migrations/ tooling
with the Ent + Atlas + Goose workflow:
go generate ./ent/...,go run ./cmd/ent-lint,task ent:check,go run ./cmd/generate-migrations(schema-driven + --sql-only),ncps migrate up(with --dry-run), andgo run ./cmd/atlas-sum-check.migrate-down skills.
cmd/{ent-lint,generate-migrations,atlas-sum-check},ent/schema/(hand-authored) vsent/(committed codegen), andmigrations/<dialect>/with embeddedatlas.sumintegrity files.changes split across N migrations), the four-step NOT NULL recipe,
and the five Ent codegen invariants (A1-A5) enforced by
cmd/ent-lint.Marks task 14.1 complete in the migrate-to-ent-and-atlas change.