Combining 25 database change files into one
To know the database’s current structure, we had to follow 25 change files in order. We combined them into one file and compared it with the live server.
The server code in production is scattered across several places. Even one app's usage records are stored and sent in two ways. Building a new server separately wouldn't make that duplication go away. We start by gathering the code in a backend folder. We keep the source of the usage records in one place and compute the statistics on the server, because if the same fact is sent two ways, then whenever they differ we first have to decide which one is right. We also deleted 2,827 lines of duplicated code.
The database was similar. The 25 change files hold how it has changed so far, but they don't tell us directly what its structure is now. So we made the current structure a single file. The history of changes is in Git, so we don't keep it separately.
Can we trust the merged file?
Merging into one file doesn't mean it matches production. We applied the new file to an empty Postgres 17 and compared it with the production server. Tables, columns, constraints, indexes, policies, triggers, functions and grants were all the same. The only differences were one line that sets default privileges and the order in which function privileges were listed.
Even so, we didn't run this file again on the production server. Creating a new server and changing a running one are different jobs. On production we applied only the changes that were needed, and aligned only the change history with the new baseline.
Written from that day’s point of view, using the documents and change history of the time. Published 2026.12.01.
