Skip to content

fix(agents-core): remove scheduled triggers tables from manage db#2929

Merged
miles-kt-inkeep merged 4 commits intomainfrom
fix/remove-deprecated-triggers
Mar 31, 2026
Merged

fix(agents-core): remove scheduled triggers tables from manage db#2929
miles-kt-inkeep merged 4 commits intomainfrom
fix/remove-deprecated-triggers

Conversation

@miles-kt-inkeep
Copy link
Copy Markdown
Contributor

No description provided.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 31, 2026

⚠️ No Changeset found

Latest commit: b1e4850

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agents-api Ready Ready Preview, Comment Mar 31, 2026 2:59pm
agents-docs Ready Ready Preview, Comment Mar 31, 2026 2:59pm
agents-manage-ui Ready Ready Preview, Comment Mar 31, 2026 2:59pm

Request Review

@pullfrog
Copy link
Copy Markdown
Contributor

pullfrog bot commented Mar 31, 2026

TL;DR — Removes the deprecated scheduled_triggers and scheduled_workflows tables from the manage database (Doltgres). These tables were previously migrated to the runtime database; this PR deletes the schema definitions, generates the Drizzle drop migration, and adds one-time cleanup scripts for purging data and dropping tables across all Doltgres branches.

Key changes

  • Remove scheduledTriggers and scheduledWorkflows from manage-schema.ts — Deletes the table definitions, relations, and agent relation references for the two deprecated tables.
  • Add Drizzle migration 0016_complex_klaw.sql — Drops both tables on the main branch via a generated migration.
  • Add delete-deprecated-scheduled-triggers.ts script — One-time script to delete all scheduled_triggers rows across every Doltgres branch, with dry-run support.
  • Add drop-scheduled-trigger-tables.ts script — One-time script to DROP TABLE on every non-main branch to work around Doltgres FK cascade merge limitations, with dry-run support.

Summary | 6 files | 4 commits | base: mainfix/remove-deprecated-triggers


Deprecated manage-side scheduled trigger tables removed

Before: scheduled_triggers and scheduled_workflows tables existed in both the manage database (Doltgres) and the runtime database (Postgres) after a prior migration.
After: The manage-side table definitions, Drizzle relations, and agent relation references are deleted. A new Drizzle migration drops the tables on main.

The tables were migrated to the runtime database in a prior change. This cleans up the dead schema from the manage side so there is a single source of truth.

Why are there two separate cleanup scripts?

Doltgres cannot reconcile ON DELETE CASCADE foreign keys during branch merges. The delete-deprecated-scheduled-triggers.ts script clears row data first, and drop-scheduled-trigger-tables.ts then drops the tables on every non-main branch. This two-phase approach ensures the Drizzle migration on main can be cleanly merged into all branches afterward.

manage-schema.ts · 0016_complex_klaw.sql · delete-deprecated-scheduled-triggers.ts · drop-scheduled-trigger-tables.ts

Pullfrog  | View workflow run | Triggered by Pullfrog | Using Claude Opus𝕏

Copy link
Copy Markdown
Contributor

@pullfrog pullfrog bot left a comment

Choose a reason for hiding this comment

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

Clean removal of the deprecated scheduled_triggers and scheduled_workflows tables from the manage schema (Doltgres). The migration drops tables in the correct FK order, the snapshot omits the removed tables, no stale references remain in the codebase, and the agentRelations closure is well-formed. The two one-off scripts are well-structured with dry-run defaults and proper Dolt branch iteration. No actionable issues found.

Pullfrog  | View workflow run | Using Claude Opus𝕏

@miles-kt-inkeep
Copy link
Copy Markdown
Contributor Author

@claude add a changeset

@inkeep-internal-ci
Copy link
Copy Markdown
Contributor

inkeep-internal-ci bot commented Mar 31, 2026

Claude finished @miles-kt-inkeep's task in 56s —— View job


Adding changeset

  • Create changeset for agents-core patch
  • Commit and push

Added changeset remove-deprecated-triggers.md for @inkeep/agents-core patch: "Remove deprecated scheduled_triggers and scheduled_workflows tables from manage database"
·

Copy link
Copy Markdown
Contributor

@claude claude bot left a comment

Choose a reason for hiding this comment

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

PR Review Summary

(0) Total Issues | Risk: Low

This PR cleanly removes the deprecated scheduled_triggers and scheduled_workflows tables from the manage database (Doltgres). The schema changes are correct, the migration drops tables in the proper order (CASCADE handles FK dependencies), and the one-time cleanup scripts are well-structured with dry-run defaults and proper resource cleanup.


💭 Consider (5) 💭

These are valid observations but acceptable tradeoffs for one-time migration scripts. The developer can reasonably choose not to address them.

💭 1) 0016_complex_klaw.sql:1-2 Drop order could match script pattern

Issue: Migration drops scheduled_triggers (parent) before scheduled_workflows (child), while the companion script correctly drops child first.
Why: CASCADE makes this work, but consistency with drop-scheduled-trigger-tables.ts (lines 95-96) would be cleaner.
Fix: Optionally reorder to drop scheduled_workflows first.
Refs: drop-scheduled-trigger-tables.ts:95-96

💭 2) 0016_complex_klaw.sql:2 Missing trailing newline

Issue: SQL file ends without a newline character.
Why: POSIX convention; some tools expect files to end with newline.
Fix: Add trailing newline.

💭 3) delete-deprecated-scheduled-triggers.ts:88-90 Silent skip on zero-count branches

Issue: Branches with the table but 0 rows are silently skipped without log output.
Why: Operators can't distinguish processed-empty branches from errored branches.
Fix: Add: console.log(\Branch "${branchName}": 0 triggers (no action needed)`);`
Refs: delete-deprecated-scheduled-triggers.ts:88-90

💭 4) scripts/*.ts Empty catch blocks swallow checkout-to-main errors

Issue: Both scripts have empty catch blocks (lines 108-109 and 107-108) when checking out back to main.
Why: If this fails repeatedly, operators get no warning. Low risk since pool is destroyed at script end.
Fix: Log a warning: console.warn(\Warning: failed to checkout main...`, err);`
Refs: delete script:108 · drop script:107

💭 5) scripts/*.ts String interpolation for DOLT_CHECKOUT

Issue: Branch names are interpolated directly: SELECT DOLT_CHECKOUT('${branchName}').
Why: Defense-in-depth: parameterized queries are safer. However, branch names come from dolt_branches system table and are validated via BranchNameSchema at creation (^[a-zA-Z0-9\-_./]+$), making practical risk very low.
Fix: Optionally use parameterized query: connection.query('SELECT DOLT_CHECKOUT($1)', [branchName])
Refs: BranchNameSchema validation


💡 APPROVE WITH SUGGESTIONS

Summary: Clean schema cleanup with well-documented one-time scripts. The tables were successfully migrated to the runtime database in a prior change, and this PR properly removes the dead schema from the manage side. The two-phase approach (delete data, then drop tables across branches) correctly handles Doltgres FK CASCADE limitations during merges. Ship it! 🚀


Discarded (2)
Location Issue Reason Discarded
scripts/*.ts:96-102, 94-101 Partial failure state if DELETE/DROP succeeds but DOLT_COMMIT fails Acceptable for one-time scripts — operator can check Dolt status manually and re-run. Script exits on error with clear message.
scripts/*.ts SQL injection in commit message interpolation Commit messages are hardcoded strings, not user input.
Reviewers (4)
Reviewer Returned Main Findings Consider While You're Here Inline Comments Pending Recs Discarded
pr-review-standards 0 0 0 0 0 0 0
pr-review-breaking-changes 2 0 2 0 0 0 0
pr-review-errors 7 0 3 0 0 0 2
pr-review-appsec 1 0 0 0 0 0 0
Total 10 0 5 0 0 0 2

Note: appsec finding merged with errors findings (SQL injection). Two partial-failure findings discarded as acceptable for one-time scripts.

@github-actions github-actions bot deleted a comment from claude bot Mar 31, 2026
Copy link
Copy Markdown
Contributor

@claude claude bot left a comment

Choose a reason for hiding this comment

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

PR Review Summary

(0) Total Issues | Risk: Low

This is a delta review of commits aec413cf6 and b1e485096 since the prior review.

Delta Changes

The migration file 0016_complex_klaw.sql was updated to:

  1. Remove CASCADE — Unnecessary since child table is dropped first
  2. Reorder dropsscheduled_workflows (child) before scheduled_triggers (parent) — correct FK order
  3. Fix statement-breakpoint — Moved to correct position between statements
  4. Add trailing newline — POSIX compliance

Prior Feedback Addressed

Item Status
💭 Drop order could match script pattern ✅ Fixed
💭 Missing trailing newline ✅ Fixed
💭 Silent skip on zero-count branches Unchanged (acceptable for one-time script)
💭 Empty catch blocks Unchanged (acceptable for one-time script)
💭 String interpolation for DOLT_CHECKOUT Unchanged (branch names validated via system table)

The remaining 3 Consider items from the prior review are in the one-time scripts (not the migration file), and remain acceptable tradeoffs for single-use migration tooling.


✅ APPROVE

Summary: Clean fix that addresses prior feedback on the migration file. The DROP order now correctly matches the companion script (child before parent), CASCADE was removed (unnecessary), and the file now ends with a newline. The one-time cleanup scripts remain unchanged and are acceptable as-is. Ship it! 🚀


Reviewers (0)
Reviewer Returned Main Findings Consider While You're Here Inline Comments Pending Recs Discarded
Total 0 0 0 0 0 0 0

Note: No sub-reviewers dispatched — delta was a 4-line fix directly addressing prior feedback. Manual review confirmed changes are correct and minimal.

Merged via the queue into main with commit 80da01a Mar 31, 2026
26 checks passed
@miles-kt-inkeep miles-kt-inkeep deleted the fix/remove-deprecated-triggers branch March 31, 2026 15:20
@inkeep
Copy link
Copy Markdown
Contributor

inkeep bot commented Mar 31, 2026

This PR removes internal database tables (scheduledTriggers, scheduledTriggersConsumer) and adds migration scripts. Since this is an internal infrastructure change with no user-facing documentation impact, no docs updates are needed.

For adding a changeset, please use pnpm changeset locally to create the versioning file.

tim-inkeep pushed a commit that referenced this pull request Mar 31, 2026
)

* remove scheduled triggers tables from doltgres

* add migration sql

* fix sql

* fix breakpoint
nick-inkeep added a commit that referenced this pull request Apr 1, 2026
- Fix nested backtick rendering in constraint table (lines 38, 41)
- Clarify version pinning: note docker-compose.dbs.yml uses :latest
- Replace fictional status column example with real credentialScope from manage-schema.ts
- Add hyperlink to PR #2929 precedent
- Remove specific beta version number to reduce staleness

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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