Skip to content

Add agent_id to schedule table with index - #583

Merged
thesujai merged 2 commits into
mainfrom
feat/agent-id-in-schedule
Sep 4, 2026
Merged

thesujai merged 2 commits into
mainfrom
feat/agent-id-in-schedule

Conversation

@thesujai

@thesujai thesujai commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add agent_id to schedule table with index
Closes AGE-2097

Changes

Add agent_id to schedule table with index

How was this tested?

NA

Checklist

  • I have read the contributing guidelines
  • pnpm build, pnpm test, pnpm typecheck, pnpm lint:ci, and pnpm format:check pass locally
  • Tests added/updated where it makes sense
  • No hand-edits to generated code (packages/trueforge-sdk, .github/fern/openapi/openapi.json, docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge
  • Docs / .env.example updated if configuration or behavior changed

Note

Medium Risk
Schema migration alters FK semantics and requires successful backfill for every schedule row; failed joins would block NOT NULL, and deploys must run migrations before code that inserts agent_id.

Overview
Schedules are now tied to agents by stable agent_id (ULID) instead of only (tenant_id, agent_name). Postgres and SQLite migrations add a NOT NULL column, backfill from the existing agent join, drop the composite name FK, and add agent(id) ON DELETE CASCADE plus (tenant_id, agent_id) index (schedule_agent_id_idx) for per-agent listing.

Application code persists and returns agent_id on create (schedules API passes resolved agent id into createScheduleAndRun), and both schedule stores map the new column. agent_name remains as a create-time snapshot; uniqueness rules on (tenant_id, agent_name, name) are unchanged. Contract and dispatch tests were updated to supply agent_id.

Reviewed by Cursor Bugbot for commit e937106. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e937106

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@truefoundry/trueforge Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chiragjn chiragjn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approving with comments

…nd update foreign key constraints. Replace `(tenant_id, agent_name)` FK with `agent(id)` ON DELETE CASCADE. Update related documentation and migration scripts for consistency across Postgres and SQLite.
@thesujai
thesujai merged commit a37cdea into main Sep 4, 2026
9 checks passed
@thesujai
thesujai deleted the feat/agent-id-in-schedule branch September 4, 2026 07:03
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.

2 participants