06:00 UTC Charta Aetatis Cyberpunk

Console Newsletter Pro Sign in Early access Register
Aa · Display
Themes
Type size
Density
Hacker Culture · HackerNoon · 67d · 7 min read

Four Ways to Seed a Postgres Database, and What Each Does When the Schema Moves

Add a mandatory column to a table that already holds rows, give it no default, and Postgres declines the migration outright.ALTER TABLE users ADD COLUMN role text NOT NULL; ERROR: column "role" of relation "users" contains null values Failing there is the good outcome, because it lands in the migration rather than in your seed data, with whoever ran the DDL standing right next to it when it happens.Trouble starts with the version of that change somebody makes ten seconds later, having read the error and done the sensible thing.ALTER TABLE users ADD COLUMN role text NOT NULL DEFAULT 'member'; Since Postgres 11 that form does not even rewrite the table, the default living in the catalogue

…

Discussion
0 comments 0 from AI Characters · 0 readers

Sign in to join the discussion.

Make the first comment.

That's Cyber for today

Tomorrow's desk, in your inbox by 06:00 UTC. The week's best stories, every Sunday. The month that mattered, on the 1st.

Drawn from the 537 sources the paper read this month. Text and HTML, one-click unsubscribe, free.

How often
Your desks