skip to content

Your deploy job also applies schema migrations to the production ledger. How would you argue that design must change?

level: principalimportance: nice to knowfreq 27%

answer

  1. authority is the union of what the job does
  2. review is not scoped to the authority
  3. one merged file, one privileged statement
  4. argue blast radius, not taste
  5. code redeploys, rewritten rows may not

basics

~20 s

Argue it as blast radius, not as taste. Letting the deploy job apply migrations means one merged file executes arbitrary statements against financial records with the pipeline's identity, reviewed by people who think they are approving code. Frame the choice as which authorities the deploy identity should hold.

solid answer

~50 s

The modelling point is that a deploy identity's authority is the union of everything the job does. Adding migrations makes "run arbitrary statements against the ledger" a capability of every merged change, exercised by an identity nobody authenticates as a person. The failure is asymmetric review: a reviewer checks whether the migration applies cleanly, not whether it rewrites balances, so the second pair of eyes is not looking at the authority being granted. I would present three options with honest costs — split the database privileges so the deploy role can change schema objects but not write ledger rows; move data-affecting migrations to a separately approved path with its own identity, accepting release-ordering pain; or keep it and compensate with migration-specific review and post-deploy invariant checks. The deciding argument is reversibility: a bad code deploy is redeployed, a rewritten ledger row may have no earlier version to restore.

go deeper

for a junior

Be ready to say that whatever a deploy job is allowed to do, every merged change can cause it to do. Recognising that a migration file is executable instructions, not configuration, is the point to carry away.

for a middle

Explain how the deploy identity's authority grows with each task the job takes on, and describe how database privileges could be split so schema changes are permitted while row rewrites on sensitive tables are refused.

for a senior

Demonstrate that you can spot the review asymmetry — a control that exists but is not scoped to the authority — and propose a change that fails closed at the database rather than relying on someone noticing during review.

for a principal

Own the decision with priced alternatives: privilege separation, restricting the shape of permitted migrations, or a separately approved path with its ordering cost. Lead with irreversibility, recommend one, and be explicit about what each option does not fix.

## The modelling claim A deploy job's identity is not "the credential to deploy". It is the union of every authority the job exercises, and the model should draw it that way. Once migrations are part of the deploy step, the pipeline holds application deployment authority *and* the ability to execute arbitrary statements against the production database. From the diagram's point of view, a data flow now runs from a file in the repository, through the deploy process, into the store that holds the money — and every merged change rides it. ## Why review does not cover it The attacker here need not be an outsider. It is a developer whose change is reviewed for logic by a colleague who is not thinking about database authority at all. Migration review in most teams asks: does it apply, is it reversible, will it lock a table for too long. It does not ask: what does this statement do to the rows. The reviewer approves the change with no sense that they are authorizing a money-affecting operation, and the resulting production change is attributed to the pipeline identity rather than to either of them, which is a repudiation problem on top of an authorization one. That asymmetry is the heart of the argument. The control everyone points to — code review — is real, but it is not scoped to the authority being exercised. A control that exists but does not look at the threat is not a mitigation. ## Framing the argument for a decision-maker Do not argue that running SQL from a pipeline is inelegant. Argue three things: 1. **Authority.** One merged file executes with an identity permitted to rewrite financial records. Name what that identity can do today, in plain language. 2. **Coverage.** Nothing in the review path is scoped to that authority, so the likelihood is not held down by the control we claim holds it down. 3. **Reversibility.** A bad code deploy is undone by deploying again. A migration that overwrites rows in place may have no prior version to restore, and reconstructing a ledger from backups plus replay is an incident measured in days, with regulatory exposure attached. ## The options and their real costs **Split the database privileges.** Give the deploy identity rights over schema objects and withhold row-level write rights on the ledger tables, so an unbounded rewrite is refused by the database itself rather than by a reviewer's attention. This is usually the cheapest large reduction available. Cost: some legitimate data backfills stop working through the pipeline and need another route, and someone must own the privilege model as tables are added. **Separate the path.** Move migrations to their own gated flow with its own approver and its own identity, distinct from application deploys. Cost is real: you reintroduce ordering problems — the application version that expects the new column versus the schema change that has not run — and you have made release engineering harder for every team, in exchange for a boundary that only matters on the tables that hold value. **Keep it and compensate.** Require a named second reviewer specifically for migration files, forbid data-mutating statements by policy, and run invariant checks against the ledger after every deploy so a bad change is detected in minutes. Cost: it depends on human diligence and on detection rather than prevention, which is exactly the class of control that decays. **Restrict the shape of migrations.** Permit structural changes through the pipeline, and require anything that rewrites existing rows to run as a reviewed operational task with its own authorization. This splits by risk rather than by mechanism and is often the pragmatic middle. ## How to close There is no single right answer, and a principal is expected to say so while still recommending one. My recommendation is normally privilege separation first, because it converts a policy hope into a database refusal and costs least; then restricting migration shape; and a fully separate path only where the value at stake justifies the ordering pain. What I would not accept is the status quo defended on the grounds that it has never gone wrong: the model's job is to price a consequence that is irreversible before it is realised, and "we review everything" is a claim about diligence, not about authority. ## Keeping scope honest This is a question about what authority the delivery path holds, not about database administration practice or about how migrations should be authored. The output of the exercise is a decision about the deploy identity and about which flows into production data are permitted to originate from a merged commit.

  • How would you split credentials so a migration cannot rewrite ledger rows?
    Use two database identities with different grants: one permitted to alter schema objects, another permitted to write rows, and let the deploy job assume only the first. An unbounded update against the ledger then fails at the database rather than depending on a reviewer noticing. Legitimate backfills move to a separately authorized path.
  • The team says migrations are reviewed like any other code. Why is that not enough?
    Because the review is not scoped to the authority being exercised. Reviewers check that a migration applies, is reversible and does not lock for too long; they rarely ask what it does to the rows. A control that exists but does not examine the threat is not mitigating it, and the model should record it as such.
  • What if migrations run in a pre-deploy step a human triggers manually?
    It only helps if that human sees the statements and is authorized over the data, rather than clicking to unblock a release. Otherwise you have added latency and a rubber stamp while the same identity executes the same statements. The gate has to change what is permitted, not just who starts it.
  • How do you present this to leadership without sounding like you are blocking delivery?
    Lead with the option that costs least — privilege separation — and quantify what it does not break. Show the irreversibility argument rather than a generic risk score, and offer the expensive option (a separate approved path) as a choice for the highest-value tables only. A recommendation with priced alternatives reads as ownership, not obstruction.

saying these in an interview costs you the question

  • Argues from taste rather than from what the identity can do
  • Assumes code review already covers migration content
  • Treats a bad migration as rollback-equivalent to a bad deploy
  • Proposes a separate pipeline without naming the ordering cost
  • Ignores that the change is attributed to the pipeline identity
  • Says it has never gone wrong, so the risk is low

context