Menu

A whole second interview format cost us two columns, one CHECK constraint and a 312-byte migration
📰

A whole second interview format cost us two columns, one CHECK constraint and a 312-byte migration

DEV Community: postgres·Daniel Pertu·16 days ago
#koZfQ9HO
#devtopostgresql#devto#dev#track#null
Reading 0:00
15s threshold

Our interview practice product grew a second format last night: the original one-way video flow for early careers, and a new live-style track for experienced hires and returners. Different question flow, different timings, different marking, same product.

The database change for all of it is migration 0053 , which is 312 bytes:

ALTER TABLE "interviews" ADD COLUMN "track" text DEFAULT 'early_careers' NOT NULL ; --> statement-breakpoint ALTER TABLE "interviews" ADD COLUMN "config" jsonb ; --> statement-breakpoint ALTER TABLE "interviews" ADD CONSTRAINT "interviews_track_valid" CHECK ( "interviews" . "track" IN ( 'early_careers' , 'experienced' ));

Enter fullscreen mode

Exit fullscreen mode

The backfill that is not there

DEFAULT ... NOT NULL on a populated table used to mean a full rewrite, so the folklore is still to add the column nullable, backfill in batches, then set NOT NULL .…

Continue reading — create a free account

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