Menu

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

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

DEV Community: typescript·Daniel Pertu·19 days ago
#3ddsMzJk
#devtotypescript#devto#dev#migration#schema
Reading 0:00
15s threshold

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

Enter fullscreen mode

Exit fullscreen mode

Seventy times more generated metadata than SQL. None of the JSON runs against the database. All of it is in git, on purpose, and deleting it would break the next migration. This is a post about what that JSON is and what it buys.

What the SQL looks like

All 32 files together are 36 KB and 225 statements. The smallest is 51 bytes:

ALTER TABLE "campaigns" ADD COLUMN "logo_url" text ;

Enter fullscreen mode

Exit fullscreen mode

The largest is the first one, 8.4 KB, which creates nine tables. The median is one or two ALTER TABLE lines.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.