Urgent.News

What's breaking now, across thousands of outlets.

Tech

Our 32 migrations are 36 KB of SQL, and the folder they live in holds 2.4 MB of JSON

Nakodo has 25 tables and 318 columns. Getting there took 32 migrations, generated by drizzle-kit from a TypeScript schema file, and the drizzle/ folder they live in is the second largest directory in the repository. Here is the ratio that started this post: 32 .sql files 35,819 bytes 33 .json files 2,495,839 bytes Seventy times more generated metadata than SQL. None of the JSON runs against the…

Nakodo's 32 migrations are contained within a drizzle/ folder that occupies 2.4 MB of space. These migrations are generated from a TypeScript schema file using drizzle-kit, and the JSON files within the folder hold 35,819 bytes of data, while the SQL files contain 33 bytes. There are 70 times more generated metadata than SQL.

All 32 migration files together consist of 36 KB of content and 225 statements, with the smallest file being 51 bytes that adds a logo URL column to the campaigns table. The largest file is 8.4 KB and creates nine tables. The median file contains one or two ALTER TABLE lines, and 29 out of the 32 migration files have machine-picked names.

The JSON files play a crucial role in the migration process. There is a _journal.json file that lists the 32 entries, each containing information such as the index, version, timestamp, tag, and breakpoint comments. Additionally, there are 32 snapshots, one for each migration, which describe the schema after that particular migration. These snapshots are complete descriptions of the schema, including tables, columns, indexes, foreign keys, and bytes.

The JSON files do not run against the database, as they serve as generated output and are not edited after being written. The snapshots, not the database or the SQL, are relied upon by drizzle-kit. Every snapshot has its own ID and the previous snapshot's ID, forming a chain that allows for detectable parallel generation and enables checking whether changes were truly reverted or if something survived.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Your Order API Needs More Than an Idempotency Key

An order API can accept an Idempotency-Key header on every request and still create a second order for the same intended purchase.

  • Idempotency key alone insufficient for single order guarantee
  • SQLite unique constraint on key ensures durability
  • Python script maintains single transaction for lookup & insertion

More from Saturday 31 October →