Skip to content

feat(schema): compare jobs in the drift report - #41

Merged
ProjectAJ14 merged 3 commits into
mainfrom
feat/job-drift
Nov 2, 2026
Merged

ProjectAJ14 merged 3 commits into
mainfrom
feat/job-drift

Conversation

@ProjectAJ14

@ProjectAJ14 ProjectAJ14 commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

What

The drift report ("compare QA with PROD") now covers scheduled jobs as well as procedures, functions, views and triggers. Follow-up to #38, from user feedback asking for SQL jobs in the compare.

  • Server: getJobDefinitions (server/services/jobs.ts) reads each SQL Server Agent / pg_cron job on the connection's database as text: its enabled schedules, plus each step's name, subsystem and command. getDrift compares both sides and returns a jobs section with identical, items (differs / only_left / only_right, with the job id on each side) and unavailable.
  • UI: the drift modal shows a Jobs section under the objects. A row opens the job on each side it exists on, with this connection's tab in front.
  • MCP: compare_objects lists jobs with their id per connection, so an agent can follow up with get_job.

Decisions

  • Matched by name. Job ids differ per server. An unnamed pg_cron job is shown as (unnamed job <id>) and matched on a SHA-256 of its command. The report never carries command text, since reading a command is an audited JOB_VIEW.
  • Enabled state is not compared. A job paused outside production on purpose isn't drift. The schedule and commands are compared.
  • Another database's step is compared by its placeholder, never by its command, so it still never leaves the server.
  • Best effort. If one side lacks the grant to read jobs, or the read fails, the report names that side under unavailable and still compares the objects. If neither side has any jobs, the jobs section is left out.
  • Jobs belong to the database, not the schema, so they appear whatever schema is picked.

Not done (from review)

  • pg_cron job names are unique per owning role, so two roles could each have a job with the same name. Matching on name plus owner would show false drift when the owner differs per environment, so this is left as is.
  • Azure SQL Database (no msdb) shows the SQLAgentReaderRole message, the same as the existing job list does.

Verified

  • npm test: 2429 tests pass, coverage still 100%. Format, lint (0 errors) and typecheck are clean.
  • End to end on npm run dev:db (real pg_cron, QA vs PROD):
    • a job paused only in PROD stays identical;
    • a changed schedule shows as differs;
    • a QA-only job shows as only on QA;
    • an unnamed job with different ids on each side matches.
  • In the browser, the modal lists the jobs and clicking vacuum-orders opened both sides' job tabs.

🤖 Generated with Claude Code

The drift report now lists the SQL Server Agent and pg_cron jobs that
differ between two connections, or exist on only one. Jobs are matched
by name (ids differ per server) and compared by a hash of their enabled
schedules and steps; enabled state is left out, since a job paused
outside production is not drift. A side without the grant to read jobs
is named instead of compared. The modal opens a job on each side it
exists on, and the MCP compare_objects tool lists jobs with their ids.
A failure to read jobs now names the side in the report instead of
failing the object comparison with it. An unnamed pg_cron job is
matched by its command, since its id differs per server, and the Agent
schedule read is limited to this database's jobs.
A drift report carries names only; reading a job's command is a
JOB_VIEW and is audited. An unnamed pg_cron job was shown by its
command, which handed that text to any reader of the report. It is now
shown as "(unnamed job <id>)" and matched on a separate key, a SHA-256
of its command.
@ProjectAJ14
ProjectAJ14 merged commit e579005 into main Nov 2, 2026
1 check passed
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.8.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant