fix(schedules): backfill agent_run_schedules deleted_at/version on early-deployed envs#341
Merged
Merged
Conversation
…eployed envs Revision 3b1c9d2e4f6a was amended after it had already been applied in some environments: deleted_at and version were added to its create_table after the fact. Alembic tracks applied revisions by id, so those environments stay stamped at 3b1c9d2e4f6a and never re-run the revision, leaving their table without the two columns. The ORM selects both, so reads fail with UndefinedColumnError; environments that first applied the final create_table are unaffected. Add a follow-up revision that adds both columns with ADD COLUMN IF NOT EXISTS: a no-op where create_table already added them, a repair where it did not. Schema-only and metadata-cheap (constant/non-volatile defaults), no backfill. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
deleted_at/version belong to the parent revision's final create_table; this repair migration only re-adds them where the parent ran in an earlier form. Dropping them on downgrade would strip parent-owned columns from environments that created the table whole. Addresses Greptile P1 on PR #341. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
NiteshDhanpal
approved these changes
Jun 29, 2026
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.
What
Adds a follow-up Alembic revision (
e7f8a9b0c1d2, child of3b1c9d2e4f6a) that adds thedeleted_atandversioncolumns toagent_run_scheduleswithADD COLUMN IF NOT EXISTS.Why
Revision
3b1c9d2e4f6a(theagent_run_schedulescreate_table) was amended after it had already been applied in some environments —deleted_atandversionwere added to itscreate_tableafter the fact. Alembic tracks applied revisions by id, not by content, so any environment already stamped at3b1c9d2e4f6anever re-runs the revision and never picks up the added columns. The ORM selects both columns, so reads fail with:Environments that first applied the final
create_table(i.e. created the table in one shot with all columns) are unaffected.Fix
A new revision is the only thing Alembic will execute on already-stamped environments. It adds both columns idempotently:
create_tablealready created them (healthy envs)3b1c9d2e4f6a)Schema-only and metadata-cheap — both columns add with a constant/non-volatile default (or nullable), so no table rewrite and no backfill. Passes the migration linter (
no findings).Notes
3b1c9d2e4f6a— editing an already-applied revision does nothing for the environments that already ran it.initial_input_methodcolumn (dropped from the revision in a later edit) may persist as an unused, harmless extra column on early-deploy envs; the ORM doesn't reference it, so it's left as-is.🤖 Generated with Claude Code
Greptile Summary
This PR updates the follow-up migration for
agent_run_schedulesrepair columns. The main changes are:deleted_atwhen missing on early-deployed databases.versionwith a default of1when missing.Confidence Score: 5/5
Safe to merge: the migration is narrowly scoped, idempotent for already-healthy databases, and avoids destructive downgrade behavior.
The change adds only missing repair columns with guarded DDL and leaves existing parent-owned schema intact, matching the described Alembic recovery scenario.
What T-Rex did
Reviews (2): Last reviewed commit: "fix(schedules): make backfill migration ..." | Re-trigger Greptile