Fix org creation crash on Postgres - #4436
Conversation
|
Here's a visual recap of what changed: Open the full interactive recap |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Builder reviewed your changes and found 1 potential issue 🟡
Review Details
Incremental Code Review Summary
The latest commit addresses both findings from the previous review: Clips now has migration v70 to widen existing lease tables, and the email log bootstrap now widens legacy created_at columns after ensuring the table. The org and SSO migrations remain additive and correctly separate fresh-database definitions from upgrades. The updated BIGINT Drizzle mappings also use numeric mode consistently with millisecond Date.now() values.
New Finding
🟡 MEDIUM: Existing app_secrets tables are still not widened. The schema and fresh-table path now use BIGINT, but the secrets storage bootstrap has no migration or widenIntColumnsToBigInt call, so upgraded deployments can still fail credential/OAuth writes when Date.now() exceeds PostgreSQL int4 range.
The two previous review threads were resolved after verifying their fixes. No other new confirmed issues were identified.
Risk assessment: Standard risk (database schema and migration behavior).
🧪 Browser testing: Skipped — this PR only modifies backend/schema/config/template ignore files, with no user-facing UI impact.

Org creation and SSO login were crashing because a few timestamp columns were too small to hold the values written into them. This fixes those columns and a couple of related spots with the same problem.
Summary
Fixes a bug that made org creation (and SSO login) crash on a fresh database, cleans up a few related timestamp columns that had the same problem waiting to happen, and ignores some local dev files that shouldn't be tracked by git.
The bug
Creating a new organization was failing with an error like
value "1788715962713" is out of range for type integer. The root cause: several database columns that store timestamps were declared asINTEGER, but the code writes millisecond timestamps into them (e.g.Date.now()), and those numbers are too big to fit in a regular integer. This affected every app, not just one template, since organization creation is shared framework code.The same problem existed in the SSO login tables, and in a background cleanup job in the Clips app.
What changed
INTEGERtoBIGINTin: organizations, org members, org invitations, app member roles, workspace apps, SSO flow state, and SSO one-time tokens.BIGINTcolumns but were still described as smaller integers in code, which could have caused silent data bugs the next time someone read from them.Also included
Added
data/*.lockto the.gitignorefile in every template. Running an app locally creates a lock file for its local database, and that file was not being ignored, so it showed up as an untracked file in git status.