Why the database stops being readable
Once schema changes get split across an ORM model, a migration file, and a bit of application code nobody wants to touch, the database stops feeling like a single thing. It turns into a set of hints. The model says one thing, the migration says another, and the runtime behavior depends on whatever the app happens to do after the row is saved. By the time a reviewer opens the pull request, they may be looking at generated output instead of the actual SQL that will run, which is a bit like proofreading a translation of a translation and pretending nothing can go wrong.
That’s where teams lose sight of the real schema. An ORM can describe tables in a tidy, friendly way, but it often strips out the gritty details that matter later: defaults that fire on insert, nullability that blocks a backfill, a foreign key that quietly changes delete behavior, or a trigger that edits a value after the application writes it. The review looks clean because the abstraction looks clean. The live database is less polite.
A schema review that never leaves the ORM is really a review of a story about the database, not the database itself.
The drift usually starts small. Someone patches a production issue by editing the database directly. A migration lands in staging but never gets applied in the same order everywhere. A branch sits around long enough that the schema file in git and the schema in production stop matching. By the time the next change comes through, reviewers approve something that no longer describes the actual live structure. That mismatch is easy to miss because the diff still looks sensible. The trouble is that “sensible” and “what is deployed” are not the same thing.
This is also why incidents often show up far away from the obvious place. A missing column is easy to spot. A broken query is noisy. Hidden behavior is sneakier. A trigger can rewrite values after insert and break downstream assumptions without any application error. A policy can block a background job only in one region or one role. An index can disappear, and everything still works, just more slowly, until a monthly report or a price sync starts timing out under load. A database does not need to be visibly broken to cause trouble. It only needs one quiet mismatch.
The practical pain is that these failures rarely announce themselves during code review. They show up in job logs, support tickets, and those lovely “why did this row change itself?” moments that make a team question their weekend plans. The application code may look fine. The migration may even be correct in isolation. What slips through is the gap between what the reviewer thought the schema would do and what the database actually does when rows are inserted, updated, or read under real conditions.
That gap gets wider when structure, behavior, and access rules live in different places. One file defines the columns. Another defines the index. A third hides trigger logic. Policy code sits somewhere else again, often in a format that application engineers never inspect unless something breaks. At that point, the schema is no longer legible in plain text. It has become a scavenger hunt.
A better review path starts with the opposite assumption: if the database is going to affect production behavior, it should be readable before deploy time. Tables, indexes, triggers, and policies need to be visible together, in one place, so a reviewer can ask ordinary questions and get ordinary answers. What gets written? What gets blocked? What mutates on the way in? What changes the read path? If those answers require three tools, two abstractions, and a guess about how the ORM compiled the change, the review surface is already too thin.
That single view matters because it turns schema review from guesswork into inspection. You can compare the intended structure with the actual SQL. You can spot drift before it lands. You can see whether a hidden trigger will rewrite data that another service expects to remain untouched. You can check whether access rules match the job or API route that needs to run. The next section gets into the exact objects that belong in that review, but the basic idea is simple: if the database is going to behave like part of your application, stop letting it hide behind abstractions.

What belongs in one schema review
Once you stop treating the database like a pile of hidden side effects, the next question is simpler than it looks: what should a reviewer actually see in one pass? The answer is not just “the tables.” A useful schema review gives you the shape of the data, the rules around it, and the bits of behavior that can change what gets stored after the INSERT or UPDATE has already looked fine.
If a change can alter production data, query cost, or access rules, it should be visible before the deploy, not discovered by a tired pager at 2:13 a.m.
Start with tables and columns, because that is the base contract. A reviewer should be able to read the type of each column, whether it accepts NULL, what default it uses, and which fields make up the primary key. That sounds basic, and it is, but basic is where a lot of trouble starts. If a timestamp defaults to now() in one place and is filled by the application in another, you already have a split-brain schema. If a column is nullable because “we might need it later,” that decision should be visible right next to the rest of the table definition, not buried in a migration comment that nobody opens after lunch.
For teams using a declarative schema, this is the part that usually pays off fastest. You want the table definition to read like an actual contract. PostgreSQL’s CREATE TABLE syntax is a decent reference point because it exposes the things that matter in plain SQL: data types, defaults, constraints, identity columns, and relationships. A review that can read like that is a review humans can reason about without translating ORM jargon in their heads.
Indexes belong in the same review, even though they get treated like an afterthought far too often. They change how the database answers questions, which means they change query plans. They also change write cost, because every insert and update has to keep those index structures in sync. That tradeoff gets missed when a migration says “add index for performance” and nothing else. Performance for which query? How often? On what cardinality? A reviewer should be able to see whether an index matches an actual access pattern, or whether it was added because someone spotted a slow endpoint once and wanted the warning light to stop blinking.
There is also a practical angle here: some indexes are there to support uniqueness, while others are there to speed up lookups or sorts. Those are not the same thing, even if the DDL looks similar. A unique index prevents duplicate values. A plain index mostly helps reads. A composite index can help one query shape and do very little for another. If the review surface shows the table and the indexes together, that tradeoff becomes much easier to discuss before the change lands. If you need to inspect a schema snapshot in plain text, pg_dump can help produce a readable version of the structure, which is often less annoying than trying to reverse-engineer intent from a migration chain. PostgreSQL documents that here: pg_dump.
Triggers are the part of the schema that tend to behave like the quiet coworker who keeps moving your desk after you leave. They can mutate rows, fill audit fields, mirror data into another table, or reject changes based on conditions that aren’t obvious from the application code. That is why they belong in the same review. If a trigger changes a column behind the scenes, the reviewer needs to know. If it kicks off a side effect, same story. The trigger body is operational logic, not decoration, and it can create surprising coupling between tables that looked unrelated at first glance. PostgreSQL’s trigger docs are worth keeping handy for this exact reason: CREATE TRIGGER.
Policies and access rules need the same treatment. Row-level security, grant changes, and policy definitions can make a schema behave very differently for one role versus another. A table can look fine on paper and still fail in production because a background job can no longer see the rows it needs. Or a policy can allow writes from one service account but block reads from another, which is a cheerful surprise if you enjoy incident reviews. These rules belong beside the structure, not off in a separate permissions document that nobody checks during a database migrations review. If access logic changes, reviewers should see it as part of the schema, because it changes what the database will actually let the application do.
Constraints and foreign keys usually sit in the same conversation too, even if the headline objects are tables, indexes, triggers, and policies. They are the guardrails. A NOT NULL column says a value must exist. A CHECK constraint says the value must fit a rule. A foreign key says a relationship must point at something real. Leave those out of review, and you end up approving a schema that looks tidy while quietly allowing bad data to drift in through a side door. Nobody wants that kind of surprise after deploy.
So the review surface should be broad enough to answer a few simple questions in one sitting: what data exists, how it is indexed, what hidden logic runs on it, and who can touch it. If those answers are split across tools, people start guessing. If they sit together in the same declarative schema view, the discussion gets a lot less foggy. And that makes the next step easier, because once the objects are all visible, you can build a workflow that keeps the review readable from the first draft through the final migration.
A practical workflow that makes schema changes legible
Once you know what belongs in the review, the next problem is simpler to name and harder to solve: how do you make the change readable before it lands in production?
The cleanest answer is to keep a declarative schema file as the source of truth. That means reviewers can inspect the intended end state directly, instead of trying to infer it from ORM objects, generated migration classes, and a pile of app code that may or may not be in sync. The schema file should describe tables, columns, indexes, triggers, and policies in one place, with the live database treated as the thing that gets built from that source, not the thing everyone hopes still matches it.
That alone cuts down on schema drift, which is usually where the weirdness starts. A model changes in the application layer, a migration gets edited by hand, a teammate reorders a couple of statements, and suddenly the reviewed change is no longer the deployed change. Nobody meant to create that gap. It still happens.
If the review only shows a model diff, you’re reviewing intent, not the SQL that will hit production.
The next step is to generate type-aware SQL or migration output that shows the exact DDL that will run. High-level ORM output is handy for application code, but it often hides the part that matters most to the database: the actual statements. A reviewer should be able to see CREATE TABLE, ALTER TABLE, CREATE INDEX, CREATE TRIGGER, and policy changes in plain text. If the migration tool can emit SQL cleanly, use that. If it can’t, that’s a strong hint to add a layer that does.
This is where a little ritual helps. Open the generated SQL, read it top to bottom, and check each object in sequence instead of scanning for broad approval. Table structure first. Are the types right? Are nullable columns actually supposed to be nullable? Did a default sneak in where it shouldn’t? Are foreign keys and constraints where you expect them?
Then move to indexes. Don’t just ask whether an index exists. Ask what query pattern it serves, what write cost it adds, and whether the column order still matches the filter and sort logic in the application. PostgreSQL’s CREATE INDEX syntax makes the shape of that decision visible, which is more useful than a one-line ORM abstraction that says “added index” and leaves the rest to imagination. If the SQL no longer lines up with the query that uses it, you catch that before the deploy, not after a page wakes someone up at 2 a.m.
A similar habit works for triggers. Read the trigger definition as if it were a small program hiding inside the database, because that’s what it is. What fires it? What does it modify? Does it write audit rows, normalize values, or kick off side effects that the application code now depends on? If the trigger logic is hard to follow in the generated SQL, it will be harder to debug later.
Policies deserve the same treatment. Access rules can look tidy in a migration diff and still block a job that was never part of the original test path. PostgreSQL’s CREATE POLICY syntax is worth reading directly for that reason. A policy that works for the app user might quietly fail for a background worker, a reporting role, or a maintenance task that runs under a different identity. Those failures tend to show up at the least convenient moment, which is a very database way of being annoying.
That review habit works best when two kinds of people are in the loop: application engineers who know why the change exists, and database-aware reviewers who know what the SQL will do once it gets to the server. One group can explain the feature. The other can spot the places where the feature and the database behavior part ways. Neither should be left guessing.
A practical workflow often looks like this:
- Write the schema change declaratively. 2. Generate the SQL that will actually run. 3. Read the diff object by object. 4. Check the expected table shape, index intent, trigger behavior, and policy effects. 5. Fix mismatches before anyone opens a deploy window.
That fifth step sounds obvious, which is usually how you know a team skips it when things get busy.
The nice part is that this doesn’t require heroics. A reviewer can open the SQL in a terminal, inspect it with familiar PostgreSQL tools, and compare it against the application’s expectation. If you want to see what that looks like in the shell, the PostgreSQL psql reference is a good companion for reading and running migration output without turning it into a mystery novel. The point is not to make people memorize database internals. The point is to make the change visible in plain text so the review can do its job.
When that workflow is in place, mismatches stop hiding in the shadows. An index that no longer matches the query stands out. A policy that blocks a new worker shows up before release. A trigger that rewrites rows in a way the app didn’t expect gets questioned while it’s still cheap to change.
That’s the part teams usually want, even if they don’t say it out loud: fewer surprises, fewer “wait, why is this behaving like that?” moments, and a review process that reads like a real change to the database instead of a polite summary of one.
Make the review surface part of production discipline
By the time a schema change reaches review, it should already be understandable in plain text. Not sort of understandable after a pair of Slack threads and a whiteboard sketch. Actually understandable. That’s the standard worth setting for backend engineering teams that care about production stability.
If a change needs tribal knowledge to make sense, it’s not ready for deploy.
That sounds almost too simple, which is usually a good sign. A review surface that shows tables, indexes, triggers, and row-level security rules in one place cuts down on the usual surprises: a migration that drifts from what’s live, a trigger that quietly mutates rows, a policy that blocks a background job, or an index that no longer matches the query path the app now uses. Those bugs tend to show up late, often after someone has already merged the change and moved on to the next ticket. Nobody enjoys learning that a “small” schema tweak also changed write behavior at 2 a.m.
A good review process does a few boring, practical things well. It makes the intended end state obvious. It lets someone scan the table definition and see the column type, nullability, default, and relationship without translating from ORM objects in their head. It puts index changes beside the table change so the reviewer can ask whether the access pattern still makes sense. It shows trigger logic without hiding it behind application code. It makes access rules visible enough that row-level security isn’t treated like a surprise feature that shows up after deployment with a badge and a clipboard.
That review discipline pays off in a very ordinary way: fewer drift bugs, fewer “wait, why did this job stop writing rows?” moments, and less time spent sorting out whether the database or the application layer is responsible for a behavior change. The payoff is not glamourous. It’s quieter than that. You spend less time debugging schema history and more time shipping changes that behave the way people expect.
ORMs still have a place. They can keep application code tidy, reduce boilerplate, and help teams move faster when the model is simple. The problem starts when the ORM becomes the only readable version of the schema. At that point, the real database lives in three places at once: generated code, migration files, and someone’s memory. That’s a terrible setup for review. So keep the ORM if it helps, but don’t let it become a curtain. The database should remain legible outside the abstraction layer, because that’s where reviewers can inspect what will actually run.
A simple rule of thumb works well here: if someone on the team cannot explain the change from the schema review alone, the change isn’t ready. That person doesn’t need to be the person who wrote it, either. In fact, they probably shouldn’t be. Fresh eyes catch the awkward parts faster, especially when a migration touches a table that already carries a few years of habits, assumptions, and one-off fixes.
The goal, then, is not dramatic process. It’s a review that feels almost boring in the best possible way. The diff is readable. The behavior is obvious. The access rules are visible. The database does what the review says it does, and the team gets to keep its weekend.




