Skip to content

docs(data-modeling): document declarative triggers via ORM SDK#190

Closed
pyramation wants to merge 9 commits into
mainfrom
feat/document-declarative-triggers
Closed

docs(data-modeling): document declarative triggers via ORM SDK#190
pyramation wants to merge 9 commits into
mainfrom
feat/document-declarative-triggers

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

Documents the declarative trigger catalog (shipped in constructive-io/constructive-db#2414) as ORM SDK–only API docs, per this repo's "document the SDK surface, never raw SQL" rule. Custom triggers are now authorable via db.triggerFunction.create + db.trigger.create — this teaches agents that surface.

Authoritative home is constructive-data-modeling (alongside constraints/indexes):

  • New references/triggers.md — full reference: two-step flow (function first, then trigger), field table (timing, events[], forEach, transitionOldName/transitionNewName, whenClause), transition tables + statement-level, and the whenClause condition DSL (shared with JobTrigger/EventTracker).
  • SKILL.md — new "Triggers" section + whenClause/transition trigger phrases in the description, a "When to Apply" bullet, and a references-table row.

Example documented:

db.triggerFunction.create({ data: { databaseId, name: 'audit_fn', code: 'BEGIN RETURN NULL; END' } })
db.trigger.create({ data: {
  databaseId, tableId, name: 'audit', functionName: 'audit_fn',
  timing: 'after', events: ['update'], forEach: 'statement',
  transitionOldName: 'o', transitionNewName: 'n',
  whenClause: { field: 'status', op: 'IS DISTINCT FROM', row: 'OLD' },
} })
// → CREATE TRIGGER audit AFTER UPDATE ON t
//     REFERENCING OLD TABLE AS o NEW TABLE AS n
//     FOR EACH STATEMENT EXECUTE FUNCTION audit_fn();

Also: a router row in constructive-features/SKILL.md, a "Custom Triggers" subsection in root features.md, and repackaged constructive-data-modeling.zip / constructive-features.zip.

Note: a trigger row without functionName is registration-only and is documented as not provisioned, matching the backend behavior that keeps existing catalog rows/generators unaffected.

Link to Devin session: https://app.devin.ai/sessions/3876baca530b465f9aec29a94eeb413b
Requested by: @pyramation

Add SDK/ORM documentation for the declarative trigger catalog (db.trigger.create
+ db.triggerFunction.create): timing, events, forEach, transition tables
(REFERENCING OLD/NEW TABLE AS), statement-level triggers, and the whenClause
condition DSL. New references/triggers.md, a Triggers section in the
constructive-data-modeling SKILL.md, a constructive-features router entry, and a
features.md overview subsection. Repackaged affected skill zips.

Documents the feature shipped in constructive-io/constructive-db#2414.
@pyramation pyramation self-assigned this Jul 22, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Resolve conflicts: combine trigger + identity-column keywords in the
constructive-data-modeling description; regenerate affected skill zips.
Combine FK column-list referential action keywords with the trigger keywords
in the constructive-data-modeling description; regenerate the skill zip.
Combine deferrable-constraint keywords with the trigger keywords in the
constructive-data-modeling description; regenerate the skill zip.
Keep both the new partial/expression index docs (main) and the Triggers section;
place the index paragraph with the Indexes section. Regenerate the skill zip.
Combine exclusion-constraint keywords with the trigger keywords in the
constructive-data-modeling description; regenerate the skill zip.
Keep both the new Views docs (main) and the Triggers section; combine view +
trigger keywords in the description and both references rows. Regenerate zip.
Regenerate skill zip from merged directory (SKILL.md merged cleanly).
main stopped tracking generated skill .zip artifacts (now gitignored); drop the
zips from this branch too. SKILL.md/views.md merged cleanly.
@pyramation pyramation closed this Jul 22, 2026
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