Replies: 1 comment
-
|
GitHub has a hard limit on rendered file sizes in diffs and PRs — anything over ~1MB will fail to render, and large JSON snapshots from Drizzle (especially with Postgres views) hit this easily. Here are a few approaches that have worked well: 1. Mark snapshots as generated files in This is the quickest win. Tell GitHub not to try rendering snapshot diffs inline: drizzle/meta/*.json linguist-generated=true
drizzle/*.sql linguist-generated=trueThis collapses them in PR diffs — you'll see "generated file" with a toggle instead of the full diff. Prevents the crash and actually makes PRs much easier to review. 2. Split your schema into multiple files by domain Instead of one giant schema file, break it up: Then in your drizzle config: export default defineConfig({
schema: './src/db/schema/*',
// ...
});This keeps individual migration and snapshot diffs smaller since changes are scoped to their domain. 3. Consider gitignoring snapshots and only committing SQL migrations Some teams add 4. Reduce view definition size If your Postgres views have very long SQL definitions, consider creating them in raw SQL migrations instead of inlining the full SELECT in the Drizzle schema. This keeps the snapshot smaller since the view body won't be serialized into the JSON. // Instead of this (large inline definition):
export const myView = pgView('my_view').as((qb) =>
qb.select(/* huge query */).from(/* ... */)
);
// Use an existing view reference:
export const myView = pgView('my_view', {
id: integer('id'),
name: text('name'),
// just declare the columns
}).existing();Then manage the view creation in a manual migration. I'd start with approach #1 ( |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Our snapshots have grown quite large, we have some postgres views defined which seems to be contributing to this.
This regularly causes github to crash when rendering.
Anyone have any advice/ workarounds for this?
Beta Was this translation helpful? Give feedback.
All reactions