Repository navigation
docs(skills): rewrite migration skills + add ent-schema skill - #1225
Conversation
|
Related Knowledge 1 document with suggested updates is ready for review. kalbasit's Space Development Environment with MinIOView Suggested Changes@@ -38,23 +38,23 @@
[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. The `goose` tool automatically wraps each migration in a transaction for PostgreSQL and MySQL. Adding manual transaction blocks will cause errors such as "cannot start a transaction within a transaction."
**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 (...);
```
-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. Note that SQLite migrations that use `PRAGMA foreign_keys = OFF` require the `-- +goose NO TRANSACTION` directive at the top of the file, since PRAGMA statements are incompatible with transactional wrapping.
## Running MinIO and Initialization
Start MinIO and run the initialization process using: |
711045f to
ed3bd4a
Compare
Both .agent/skills/ent-schema/SKILL.md and CLAUDE.md described A2 as the snake_case enum-type convention, which contradicted cmd/ent-lint/main.go (line 286+) and openspec/specs/ent-schema-lint/spec.md — both of which treat A2 as the "OnDelete on edge.From is forbidden" check. Reword A2 in both docs to match the actual linter invariant, and move the snake_case enum-type rule into its own section labelled as a convention enforced by code review until the schema tree gains its first field.Enum(...) declaration. Addresses gemini-code-assist comment on PR #1225 (PRRT_kwDONV6tZs6D34eU). Co-Authored-By: Claude Opus 4.7 <[email protected]>
88834a7 to
e392a8d
Compare
ed3bd4a to
056f388
Compare
Both .agent/skills/ent-schema/SKILL.md and CLAUDE.md described A2 as the snake_case enum-type convention, which contradicted cmd/ent-lint/main.go (line 286+) and openspec/specs/ent-schema-lint/spec.md — both of which treat A2 as the "OnDelete on edge.From is forbidden" check. Reword A2 in both docs to match the actual linter invariant, and move the snake_case enum-type rule into its own section labelled as a convention enforced by code review until the schema tree gains its first field.Enum(...) declaration. Addresses gemini-code-assist comment on PR #1225 (PRRT_kwDONV6tZs6D34eU). Co-Authored-By: Claude Opus 4.7 <[email protected]>
e392a8d to
490804f
Compare
056f388 to
13a2787
Compare
Both .agent/skills/ent-schema/SKILL.md and CLAUDE.md described A2 as the snake_case enum-type convention, which contradicted cmd/ent-lint/main.go (line 286+) and openspec/specs/ent-schema-lint/spec.md — both of which treat A2 as the "OnDelete on edge.From is forbidden" check. Reword A2 in both docs to match the actual linter invariant, and move the snake_case enum-type rule into its own section labelled as a convention enforced by code review until the schema tree gains its first field.Enum(...) declaration. Addresses gemini-code-assist comment on PR #1225 (PRRT_kwDONV6tZs6D34eU). Co-Authored-By: Claude Opus 4.7 <[email protected]>
490804f to
1c0dbae
Compare
13a2787 to
96faf37
Compare
Both .agent/skills/ent-schema/SKILL.md and CLAUDE.md described A2 as the snake_case enum-type convention, which contradicted cmd/ent-lint/main.go (line 286+) and openspec/specs/ent-schema-lint/spec.md — both of which treat A2 as the "OnDelete on edge.From is forbidden" check. Reword A2 in both docs to match the actual linter invariant, and move the snake_case enum-type rule into its own section labelled as a convention enforced by code review until the schema tree gains its first field.Enum(...) declaration. Addresses gemini-code-assist comment on PR #1225 (PRRT_kwDONV6tZs6D34eU). Co-Authored-By: Claude Opus 4.7 <[email protected]>
1c0dbae to
1681faf
Compare
96faf37 to
7568b3c
Compare
Both .agent/skills/ent-schema/SKILL.md and CLAUDE.md described A2 as the snake_case enum-type convention, which contradicted cmd/ent-lint/main.go (line 286+) and openspec/specs/ent-schema-lint/spec.md — both of which treat A2 as the "OnDelete on edge.From is forbidden" check. Reword A2 in both docs to match the actual linter invariant, and move the snake_case enum-type rule into its own section labelled as a convention enforced by code review until the schema tree gains its first field.Enum(...) declaration. Addresses gemini-code-assist comment on PR #1225 (PRRT_kwDONV6tZs6D34eU). Co-Authored-By: Claude Opus 4.7 <[email protected]>
1681faf to
999a958
Compare
7568b3c to
f4141c3
Compare
Both .agent/skills/ent-schema/SKILL.md and CLAUDE.md described A2 as the snake_case enum-type convention, which contradicted cmd/ent-lint/main.go (line 286+) and openspec/specs/ent-schema-lint/spec.md — both of which treat A2 as the "OnDelete on edge.From is forbidden" check. Reword A2 in both docs to match the actual linter invariant, and move the snake_case enum-type rule into its own section labelled as a convention enforced by code review until the schema tree gains its first field.Enum(...) declaration. Addresses gemini-code-assist comment on PR #1225 (PRRT_kwDONV6tZs6D34eU). Co-Authored-By: Claude Opus 4.7 <[email protected]>
999a958 to
55c9051
Compare
f4141c3 to
968ad67
Compare
Both .agent/skills/ent-schema/SKILL.md and CLAUDE.md described A2 as the snake_case enum-type convention, which contradicted cmd/ent-lint/main.go (line 286+) and openspec/specs/ent-schema-lint/spec.md — both of which treat A2 as the "OnDelete on edge.From is forbidden" check. Reword A2 in both docs to match the actual linter invariant, and move the snake_case enum-type rule into its own section labelled as a convention enforced by code review until the schema tree gains its first field.Enum(...) declaration. Addresses gemini-code-assist comment on PR #1225 (PRRT_kwDONV6tZs6D34eU). Co-Authored-By: Claude Opus 4.7 <[email protected]>
55c9051 to
1783d26
Compare
968ad67 to
94dec92
Compare
|
Automated stack merge failed during the rebase step. The |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 @.agent/skills/ent-schema/SKILL.md:
- Around line 35-45: The SKILL.md section heading and ID "A2" is inconsistent
with the lint rule implemented in cmd/ent-lint/main.go (which currently enforces
entsql.OnDelete placement on edge.From) and the note saying enum naming is not
implemented; update SKILL.md and/or cmd/ent-lint/main.go so the invariant IDs
match: either rename the documentation section currently titled "A2 — snake_case
enum-type naming" to the rule that matches the implemented check (e.g., "A2 —
entsql.OnDelete placement for edge.From") or change the implemented lint check
to enforce enum-type naming as documented; also remove or correct the line that
says enum naming is not implemented (or implement the enum naming check) so docs
and code refer to the same invariant ID and behavior.
In @.agent/skills/migrate-new/SKILL.md:
- Around line 93-94: Update the sentence describing `ent-lint` so it does not
claim coverage of all five invariants; instead state that `go run ./cmd/ent-lint
--root .` checks a subset of the five codegen invariants implemented today (or
explicitly list which invariants are implemented if known) to avoid overstating
CI coverage—edit the line referencing `ent-lint` in SKILL.md accordingly.
🪄 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: 0693eab1-b60a-459e-a023-b6e7dba75c66
📒 Files selected for processing (8)
.agent/skills/dbmate/SKILL.md.agent/skills/ent-schema/SKILL.md.agent/skills/generate-db-wrappers/SKILL.md.agent/skills/migrate-down/SKILL.md.agent/skills/migrate-new/SKILL.md.agent/skills/migrate-up/SKILL.md.agent/skills/sqlc/SKILL.mdopenspec/changes/migrate-to-ent-and-atlas/tasks.md
💤 Files with no reviewable changes (3)
- .agent/skills/generate-db-wrappers/SKILL.md
- .agent/skills/dbmate/SKILL.md
- .agent/skills/sqlc/SKILL.md
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 @.agent/skills/migrate-down/SKILL.md:
- Around line 22-27: The expand-contract steps contradict the forbidden-DDL
policy because the bullet that says "Drop the old column in migration N+2"
instructs a DROP action that the spec disallows; update the SKILL.md sequence to
remove or replace the DROP step (the "Drop" instruction referencing migration
N+2) with an alternative compliant instruction such as marking the column
deprecated and scheduling removal via an approved policy/process, or explicitly
note that DROP must be performed only after operator approval and via a separate
non-automated workflow consistent with the forbidden-DDL rules; ensure the
updated text references "migration N+2" and the "Drop" instruction so reviewers
can verify the conflict is resolved.
- Around line 33-41: The NOT NULL migration recipe omits the required
application-change deployment where the app is updated to always write the new
column before applying the NOT NULL constraint; update the doc around the
Migration A/B/C sequence to insert a new step (e.g., "Migration C: deploy app
change that always writes the column") between the BACKFILL step and the final
"ADD CONSTRAINT NOT NULL / ALTER COLUMN ... SET NOT NULL" step, and describe
that this deploy ensures no rows are left null and prevents runtime write errors
or lock failures when running the NOT NULL migration.
🪄 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: 7150369b-9ca5-4b3a-8805-b849f48054b6
📒 Files selected for processing (8)
.agent/skills/dbmate/SKILL.md.agent/skills/ent-schema/SKILL.md.agent/skills/generate-db-wrappers/SKILL.md.agent/skills/migrate-down/SKILL.md.agent/skills/migrate-new/SKILL.md.agent/skills/migrate-up/SKILL.md.agent/skills/sqlc/SKILL.mdopenspec/changes/migrate-to-ent-and-atlas/tasks.md
💤 Files with no reviewable changes (3)
- .agent/skills/sqlc/SKILL.md
- .agent/skills/dbmate/SKILL.md
- .agent/skills/generate-db-wrappers/SKILL.md
✅ Files skipped from review due to trivial changes (2)
- .agent/skills/ent-schema/SKILL.md
- .agent/skills/migrate-new/SKILL.md
Rewrites the .agent/skills/ tree to reflect the Ent + Atlas + Goose workflow: - `.agent/skills/migrate-new/SKILL.md` now drives the "edit ent/schema → go generate ./ent → cmd/generate-migrations" pipeline, with `--sql-only` for backfills + the four-step NOT NULL recipe, plus the `--skip` / `--postgres-url` / `--mysql-url` overrides for hand-translated migrations. - `.agent/skills/migrate-up/SKILL.md` documents `ncps migrate up` with `--dry-run` preview, the one-shot dbmate adoption, and the three named error states (CorruptState, ImpossibleState, DownNotSupported). - `.agent/skills/migrate-down/SKILL.md` becomes a doc on the expand-contract policy + four-step NOT NULL recipe; there is no `migrate down` command. - Adds `.agent/skills/ent-schema/SKILL.md` documenting the five codegen invariants (A1-A5) with concrete examples, cross-referencing cmd/ent-lint for live AST enforcement of A1, A2, A4. - Deletes `.agent/skills/sqlc/`, `.agent/skills/generate-db-wrappers/`, and `.agent/skills/dbmate/`. Marks tasks 14.2-14.6 complete in the migrate-to-ent-and-atlas change.
There was a problem hiding this comment.
♻️ Duplicate comments (3)
.agent/skills/migrate-down/SKILL.md (2)
33-41:⚠️ Potential issue | 🟠 Major | ⚡ Quick winNOT NULL recipe is missing the mandatory application-write transition step.
For an existing nullable column, the required sequence includes a deploy where application code always writes the field before locking
NOT NULL. The current 4-step text skips that, which can cause lock failures or runtime write errors.📝 Suggested fix
1. **Migration A**: ADD COLUMN nullable, default-able. -1. **Migration B** (`--sql-only` stub): BACKFILL existing rows. -1. **Migration C**: ADD CONSTRAINT NOT NULL (or +1. **Deploy code** that always writes a non-null value for that column. +1. **Migration B** (`--sql-only` stub): backfill existing NULL rows. +1. **Migration C**: lock the column to NOT NULL (or `ALTER COLUMN ... SET NOT NULL`). 1. **Deploy each step independently**; never combine into a single migration.🤖 Prompt for 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. In @.agent/skills/migrate-down/SKILL.md around lines 33 - 41, The NOT NULL migration recipe is missing the mandatory deploy step where application code is changed to always write the new field before locking it NOT NULL; update the sequence (around "Migration B (`--sql-only` stub): BACKFILL existing rows" and "Migration C: ADD CONSTRAINT NOT NULL") to insert an explicit "Migration B2" (or "Application write transition") deploy that updates the application code to set the column on every write and runs a rollout/verification before running the ALTER/ADD CONSTRAINT; mention the need to monitor/rollback and that this step ensures no runtime write errors or lock contention when "Migration C" runs.
22-27:⚠️ Potential issue | 🟠 Major | ⚡ Quick winExpand-contract steps may contradict stated forbidden-DDL policy.
Line 26 instructs
DROPin migration N+2, but per the previous review, the migration spec explicitly classifiesDROP COLUMN/DROP TABLEas forbidden. This creates conflicting operator guidance.📝 Suggested fix
-1. **Drop** the old column in migration N+2. +1. **Decommission** the old column via a forward-safe strategy approved by the migration spec (do not use destructive DDL in regular migrations).🤖 Prompt for 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. In @.agent/skills/migrate-down/SKILL.md around lines 22 - 27, The expand-contract steps currently instruct a DROP in "migration N+2", which conflicts with the project's forbidden-DDL policy; update the step that currently says "Drop the old column in migration N+2" to avoid any automated DROP/DROP COLUMN/DROP TABLE in migrations (e.g., change to "Mark the old column deprecated and schedule manual cleanup outside migrations" or "Perform DROP only via an approved out-of-band process after verification"), and add a short note referencing the forbidden-DDL policy to make the operator guidance consistent with the project's migration rules..agent/skills/migrate-new/SKILL.md (1)
93-94:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winOverstates what
ent-lintcurrently enforces.Line 93 says
ent-lintchecks all five invariants, but the ent-schema skill documents that only a subset is implemented today. Please align this wording to avoid false confidence in CI coverage.📝 Suggested wording adjustment
-- `go run ./cmd/ent-lint --root .` checks every schema against the five - codegen invariants. +- `go run ./cmd/ent-lint --root .` checks a subset of the five + codegen invariants currently implemented (A1, A2, A4).🤖 Prompt for 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. In @.agent/skills/migrate-new/SKILL.md around lines 93 - 94, Update the wording that claims `go run ./cmd/ent-lint --root .` "checks every schema against the five codegen invariants" to state it only validates the subset of invariants currently implemented; replace the phrase "the five codegen invariants" with something like "the subset of codegen invariants currently implemented by ent-lint" and optionally add a parenthetical or link referencing the ent-schema skill docs for the exact coverage so readers don't assume full CI coverage; modify the line where `go run ./cmd/ent-lint --root .` appears in SKILL.md accordingly.
🤖 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.
Duplicate comments:
In @.agent/skills/migrate-down/SKILL.md:
- Around line 33-41: The NOT NULL migration recipe is missing the mandatory
deploy step where application code is changed to always write the new field
before locking it NOT NULL; update the sequence (around "Migration B
(`--sql-only` stub): BACKFILL existing rows" and "Migration C: ADD CONSTRAINT
NOT NULL") to insert an explicit "Migration B2" (or "Application write
transition") deploy that updates the application code to set the column on every
write and runs a rollout/verification before running the ALTER/ADD CONSTRAINT;
mention the need to monitor/rollback and that this step ensures no runtime write
errors or lock contention when "Migration C" runs.
- Around line 22-27: The expand-contract steps currently instruct a DROP in
"migration N+2", which conflicts with the project's forbidden-DDL policy; update
the step that currently says "Drop the old column in migration N+2" to avoid any
automated DROP/DROP COLUMN/DROP TABLE in migrations (e.g., change to "Mark the
old column deprecated and schedule manual cleanup outside migrations" or
"Perform DROP only via an approved out-of-band process after verification"), and
add a short note referencing the forbidden-DDL policy to make the operator
guidance consistent with the project's migration rules.
In @.agent/skills/migrate-new/SKILL.md:
- Around line 93-94: Update the wording that claims `go run ./cmd/ent-lint
--root .` "checks every schema against the five codegen invariants" to state it
only validates the subset of invariants currently implemented; replace the
phrase "the five codegen invariants" with something like "the subset of codegen
invariants currently implemented by ent-lint" and optionally add a parenthetical
or link referencing the ent-schema skill docs for the exact coverage so readers
don't assume full CI coverage; modify the line where `go run ./cmd/ent-lint
--root .` appears in SKILL.md accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2ce627d3-8e3f-4282-9a94-918dcc19550c
📒 Files selected for processing (8)
.agent/skills/dbmate/SKILL.md.agent/skills/ent-schema/SKILL.md.agent/skills/generate-db-wrappers/SKILL.md.agent/skills/migrate-down/SKILL.md.agent/skills/migrate-new/SKILL.md.agent/skills/migrate-up/SKILL.md.agent/skills/sqlc/SKILL.mdopenspec/changes/migrate-to-ent-and-atlas/tasks.md
💤 Files with no reviewable changes (3)
- .agent/skills/sqlc/SKILL.md
- .agent/skills/dbmate/SKILL.md
- .agent/skills/generate-db-wrappers/SKILL.md
✅ Files skipped from review due to trivial changes (2)
- .agent/skills/ent-schema/SKILL.md
- .agent/skills/migrate-up/SKILL.md
Rewrites the .agent/skills/ tree to reflect the Ent + Atlas + Goose
workflow:
.agent/skills/migrate-new/SKILL.mdnow drives the"edit ent/schema → go generate ./ent → cmd/generate-migrations"
pipeline, with
--sql-onlyfor backfills + the four-step NOT NULLrecipe, plus the
--skip/--postgres-url/--mysql-urloverrides for hand-translated migrations.
.agent/skills/migrate-up/SKILL.mddocumentsncps migrate upwith
--dry-runpreview, the one-shot dbmate adoption, and thethree named error states (CorruptState, ImpossibleState, DownNotSupported).
.agent/skills/migrate-down/SKILL.mdbecomes a doc on theexpand-contract policy + four-step NOT NULL recipe; there is no
migrate downcommand..agent/skills/ent-schema/SKILL.mddocumenting the fivecodegen invariants (A1-A5) with concrete examples, cross-referencing
cmd/ent-lint for live AST enforcement of A1, A2, A4.
.agent/skills/sqlc/,.agent/skills/generate-db-wrappers/,and
.agent/skills/dbmate/.Marks tasks 14.2-14.6 complete in the migrate-to-ent-and-atlas change.