npm, twelve months after release
found in the first internal migration
Atlas Schema takes one PostgreSQL schema definition and generates three things that normally drift apart: runtime validation schemas, TypeScript types for the API layer, and a reviewable migration diff.
It exists because I kept fixing the same category of bug in different codebases, and the bug was always the same shape.
In most TypeScript services, the same data model is written down three or four times: once in the migration, once as an ORM model or type, once as a request validator, and once more in whatever the frontend believes.
These are supposed to agree. They agree at the moment they are written and diverge from then on, because there is no mechanism that forces them to stay aligned. The failure mode is quiet: a column becomes nullable, the migration ships, the validator still asserts it is present, and a null reaches production three weeks later in a code path nobody tested.
Existing tools solve pieces of this. ORMs own the model but generate weak runtime validation. Validator libraries own runtime checks but know nothing about the database. Codegen tools produce types but not validators.
Rather than inventing a schema language, Atlas Schema reads the actual PostgreSQL catalogue. Column types, nullability, defaults, constraints, enums, and foreign keys are all already recorded there, precisely and authoritatively. Anything I invented would only ever be an approximation of it.
Generated files are written to disk and committed. This was a deliberate constraint. It means a reviewer sees exactly what changed when a column changes, and it means the production bundle carries no framework — just the emitted validators.
The tool compares the current schema against the target and produces a categorised plan: additive, transformative, or destructive. Destructive operations require an explicit acknowledgement flag, which turns a dangerous default into a deliberate act.
UserId cannot be silently passed where an OrderId is expected.PostgreSQL's type system is larger than TypeScript's. Ranges, intervals, arrays of composite types, and domains have no clean structural equivalent. I settled on a documented mapping table with explicit escape hatches, and I refuse to guess — unmappable types raise an error rather than silently degrading to unknown.
Generated code has to be readable. The first version emitted correct but unreadable output, and reviewers rightly ignored it. Rewriting the emitter to produce formatted, commented, diff-friendly code took longer than the introspection layer and mattered more.
Maintaining an open-source project is a different job. Fourteen outside contributors means triage, review, and saying no to reasonable feature requests that would widen the scope past what I can maintain. I underestimated this entirely.
The first internal migration onto Atlas Schema surfaced 31 genuine type-safety defects — places where validators and the database had silently diverged. Four were reachable in production code paths.
Twelve months after release the package sits at roughly 4,200 weekly npm downloads with 14 outside contributors and 94% test coverage.
The feedback I value most came from a contributor who reported that drift detection caught a nullable-column change in CI that would otherwise have shipped. That is precisely the bug the project was written to make impossible.
I would have written the documentation site before the second feature, not after the tenth. Adoption tracked documentation quality far more closely than it tracked capability.
I would also have defined the scope boundary publicly and early. Most of the friction in maintenance came from feature requests that were individually reasonable and collectively unmaintainable, and a written scope statement would have made those conversations shorter and kinder.
Awards and results connected to this project.
There is always more detail than a write-up can carry — architecture trade-offs, what the evaluation missed, the decisions that were closer than they look. Ask.
