refactor: Push run_at / name defaulting into JobPreparer#104
Draft
CelticMajora wants to merge 1 commit intomainfrom
Draft
refactor: Push run_at / name defaulting into JobPreparer#104CelticMajora wants to merge 1 commit intomainfrom
CelticMajora wants to merge 1 commit intomainfrom
Conversation
Per Nathan's PR #103 review, the before_save :set_default_run_at, :set_name callback is magical and doesn't actually prevent anyone from adding a new before_save that skips callbacks. Move the defaulting into Delayed::Backend::JobPreparer so both the single save path and any future bulk-insert path pick up defaults from the same place, and delete the before_save wiring along with the Job#set_name and Base#set_default_run_at helpers. Add db/migrate/8_require_run_at_and_name.rb to enforce the invariant at the DB level (with a COALESCE backfill for any legacy NULL rows). Direct Delayed::Job.create! / .save without supplying run_at and name is now a DB-level NOT NULL violation -- callers should route through Delayed::Job.enqueue (which runs JobPreparer). Breaking change for anyone reaching past the documented enqueue API. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
The before_save :set_default_run_at, :set_name callback is magical and doesn't actually prevent anyone from adding a new before_save that skips callbacks. Move the defaulting into Delayed::Backend::JobPreparer so both the single save path and any future bulk-insert path pick up defaults from the same place, and delete the before_save wiring along with the Job#set_name and Base#set_default_run_at helpers.
Add db/migrate/8_require_run_at_and_name.rb to enforce the invariant at the DB level (with a COALESCE backfill for any legacy NULL rows). Direct Delayed::Job.create! / .save without supplying run_at and name is now a DB-level NOT NULL violation -- callers should route through Delayed::Job.enqueue (which runs JobPreparer).
Breaking change for anyone reaching past the documented enqueue API.