frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

Migrations turn code itself into state

https://github.com/powertime-org/pgdeclare
1•powertime•47m ago

Comments

powertime•47m ago
Unlike most languages, which tell the computer how to do a task step by step, SQL says what you want, and the database decides how. That makes databases vastly easier to use, yet SQL can be harder to build with than the rest of the app, even code that spells out every step.

The problem is that software always changes. Usually that means changing, adding, or deleting code. But changing how a database organizes its data requires "migrations" -- directions from its current state to its desired state. Because migrations are an inextricable part of life with SQL databases, (much of) SQL code in practice runs in the order it's written, so to understand any bit of SQL you must understand every bit that ran before it... and new code gets harder to write as the code base grows.

Consider two programs controlling a robot:

Brittle:

  1. drive 100 meters forward
  2. turn 90 degrees right
  3. drive another 50 meters
Resilient:

  1. turn right at the stop light
  2. stop at the first house
The brittle version is longer (i.e. worse), but the key issue is that, like SQL in practice, each step only makes sense if you know all the steps before it. Take "turn 90 degrees right". It takes you through the stop light or off a cliff, depending on where the prior commands landed you. Not so with "turn right at the stop light". Run it at the wrong time and you may turn at the wrong light, but you won't turn into a car, a house, a wall, or off a cliff because you weren't where you thought. It's much easier to reason about, build, and maintain.

This is why good engineers squeeze state handling into the smallest volume of code possible, and why the whole family of functional languages exists. But with SQL, the code isn't just handling state; the code itself is state. There's a reasonable reason: the database, unless empty, is state, so changes must consider what's in it.

It's so painful that two approaches emerged largely to sidestep it.

ORMs

The 90s saw TOPLink and later Enterprise JavaBeans: Object Relational Mappers (ORMs), which mapped non-SQL code to SQL. They let engineers write ordinary code in modules, files, and functions. It was like ordering in a foreign country from a waiter who speaks both languages but is native in neither: you usually get what you asked for, but not always. Some were better than others, but every real system leaned on the escape hatch they all have: raw SQL -- speaking to the chef directly in the local language. Then SQL was sprinkled through another language's source, hard to reason about again, and the chef got contradictory orders from you and the waiter. ORMs also brought migration tools (Rails migrations, Alembic) that made the tower of changes easier to write but no easier to read.

NoSQL

Then came a global revolt against SQL, somewhere between Google's Bigtable paper in 2006 and 2009, when Cassandra, MongoDB, CouchDB, Redis, and others proudly joined the NoSQL movement. Mongo was easy to start and iterate on, but SQL still won for many reasons. Chief among them: the data model didn't magically disappear -- it became an emergent property of the code, spreading the same poison migrations carried into the entire code base. The code became state. So after a long hype cycle, Postgres became the most-used database in the 2023 Stack Overflow developer survey, and SQL reasserted its dominance.

The end state

There are a variety of schema differs out there -- including a variety aimed just at Postgres. We couldn't find one that was both open source and worked on our code so we wrote pgdeclare. It lets people write in SQL but describe the final state without building up an ever less stable tower of changes. Reverse jenga still ends up with a pile of blocks on the floor -- it's just a bigger mess. To set expectations: some change management is inevitable and we provide our own escape hatch for that. Hopefully it works for you, and if not, pull requests are very welcome.

A Little League coach pulled aside an opposing player [Meta Glasses]

https://www.nytimes.com/athletic/7693356/2026/10/16/little-league-coach-viral-leadership-2/
1•compiler-guy•24s ago•0 comments

And Soon It Will Be Forgotten

https://desmolysium.substack.com/p/and-soon-it-will-be-forgotten
1•paulpauper•2m ago•0 comments

The Death of the Comeback

https://morbidcuriosity.substack.com/p/the-death-of-the-comeback
1•paulpauper•2m ago•0 comments

The big lie we tell ourselves as we get older

https://coached.com/essays/the-big-lie-we-tell-ourselves-as-we-get-older/
1•rohanm93•3m ago•1 comments

Lilly code editor outperforms Neovim using custom treesitter equivalent

https://tauraamui.site/blog/lilly-perf-vs-neovim-and-others
1•bloostar•3m ago•0 comments

Bill Gross bets AI can help mass produce 1M new startups

https://fortune.com/2026/10/19/bill-gross-idealab-ai-million-startups-jobs/
1•cybermango•3m ago•0 comments

Development Statistics for the 7.3 Kernel

https://lwn.net/SubscriberLink/1100241/27c42c1a81a81577/
1•cjd8•4m ago•0 comments

Show HN: CueCut Teleprompter for videos, podcasts and Zoom calls

https://getcuecut.com/
1•beerglass•4m ago•0 comments

Counterexample to Euler's Conjecture on Sums of Like Powers (1966) [pdf]

https://www.ams.org/journals/bull/1966-72-06/S0002-9904-1966-11654-3/S0002-9904-1966-11654-3.pdf?...
1•theanonymousone•6m ago•0 comments

GTA 6 release could cost US economy $1B in lost productivity in just one day

https://www.ibtimes.co.uk/gta-6-launch-billion-dollar-sick-day-1818190
2•Vaslo•6m ago•0 comments

Techno-Optimism Archive – Old Promises of New Technologies

https://technooptimism.org/
1•ohjeez•6m ago•0 comments

We Put a Browser in Everything and Called It Progress

https://dayvster.com/blog/we-put-a-browser-in-everything-and-called-it-progress/
2•ibobev•9m ago•0 comments

AI Proved the Quasi-Riemann Hypothesis. What Happens Now?

https://www.quantamagazine.org/ai-proved-the-quasi-riemann-hypothesis-what-happens-now-20261019/
1•ibobev•9m ago•0 comments

Decoding base64 in Python at 10 gigabytes per second

https://lemire.me/blog/2026/10/17/decoding-base64-in-python-at-10-gigabytes-per-second/
2•ibobev•10m ago•0 comments

Show HN: ProvLedger – stops coding agents repeating mistakes

https://github.com/yizhao95/prov_ledger
2•yzhao950213•10m ago•1 comments

The Bourgain Project

https://terrytao.wordpress.com/2026/10/19/the-bourgain-project/
1•smilelamp•10m ago•0 comments

Anthropic commits 5% of shares to new public benefit fund

https://www.cnbc.com/video/2026/10/19/anthropic-commits-5percent-of-shares-to-new-public-benefit-...
1•geox•11m ago•0 comments

I Tried to Verify Rust OSS with Lean 4 and Found Many Bugs

https://medium.com/@Koukyosyumei/i-tried-to-formally-verify-popular-rust-projects-with-lean-4-but...
3•syumei•11m ago•0 comments

Surveying the landscape of CSS microframeworks (2023)

https://blakewatson.com/journal/surveying-the-landscape-of-css-micro-frameworks/
1•ForHackernews•13m ago•0 comments

Toronto man accused of driving rental car 30k kms in just 7 days

https://toronto.citynews.ca/2026/10/19/toronto-man-rental-car-30-thousand-kms-avis-seven-days/
2•breitling•13m ago•0 comments

Linux KVM guest-host escape rated critical

https://www.theregister.com/virtualization/2026/10/19/linux-kvm-guest-host-escape-rated-critical-...
2•mooreds•14m ago•0 comments

Building a Dependency Graph of Our Python Codebase

https://www.hudsonrivertrading.com/hrtbeat/dependency-graph-python-codebase
1•Tommkruix123•14m ago•0 comments

Maths, Metal, and Mandelbrot

https://blog.jacobstechtavern.com/p/maths-metal-mandelbrot
1•jakey_bakey•14m ago•0 comments

Who Will Benefit from the AI Revolution?

https://time.com/article/2026/10/19/who-will-benefit-from-the-ai-revolution-/
1•voxleone•15m ago•0 comments

Spirit Room – Test whether agents can find and use your MCP tools

https://spiritroom.app/
1•LeonidBugaev•16m ago•0 comments

Claude Code, Codex and OpenCode Find MCP Tools

https://spiritroom.app/blog/optimise-mcp-tools-for-agents/
1•LeonidBugaev•16m ago•0 comments

The Download: preserving the Arctic permafrost, and playful AI agents

https://www.technologyreview.com/2026/10/19/1147103/the-download-preserving-the-arctic-permafrost...
1•joozio•17m ago•0 comments

Why TypeScript lets you overrule its type checker

https://www.ultracite.ai/research/type-escape-hatches
1•fmerian•19m ago•0 comments

Python's binary wheels and supply chain attacks

https://rushter.com/blog/python-binary-wheels/
1•theanonymousone•20m ago•0 comments

How tough can emoji be?

https://totaldraw.com/blog/emoji/
1•theanonymousone•22m ago•0 comments