fix: add migration for schedules CHECK constraint to include 'interval'#1063
Merged
threepointone merged 2 commits intomainfrom Mar 4, 2026
Merged
fix: add migration for schedules CHECK constraint to include 'interval'#1063threepointone merged 2 commits intomainfrom
threepointone merged 2 commits intomainfrom
Conversation
Add migration logic to fix the cf_agents_schedules CHECK constraint to include the 'interval' type by recreating the table when the old constraint is detected. Also add new columns (execution_started_at, retry_options) and ensure data is preserved, handle leftover cf_agents_schedules_new cleanup, and make the migration idempotent. Introduce TestMigrationAgent and comprehensive Vitest tests to simulate old, intermediate, and partial-migration states and verify behavior; wire the agent into test exports, worker env, and wrangler config. Minor non-functional CHANGELOG tweak and package-lock updates.
🦋 Changeset detectedLatest commit: 990bde8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1061
The
cf_agents_schedulestable's CHECK constraint ontypeonly allowed('scheduled', 'delayed', 'cron'). DOs created before the interval scheduling feature would hitCHECK constraint failedwhen trying to usescheduleEvery()orkeepAlive().Changes
Migration (
packages/agents/src/index.ts)sqlite_masterand recreates the table with'interval'included, preserving all existing dataDROP TABLE IF EXISTS cf_agents_schedules_newto handle any leftover temp tableexecution_started_atandretry_optionsto theCREATE TABLE IF NOT EXISTSso new DOs get the full schema upfrontTests (
packages/agents/src/tests/migration.test.ts)8 test cases covering:
type='interval'(reproduces the bug)'interval'sqlite_master_newtable from partial migrationscheduled,delayed,cron) survive migration