From a28e3724ae1eb2fa3a1a6ae61e63da4836415c70 Mon Sep 17 00:00:00 2001 From: Daniel Volz Date: Sun, 18 Jan 2026 08:27:29 +0100 Subject: [PATCH] docs: emphasize ALTER migration requirement for new features (#40) Added prominent warning in copilot-instructions.md that every new feature touching DB must include ALTER migrations in client.ts, not just schema.ts. This prevents production 500 errors on existing databases. --- .github/copilot-instructions.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 9a4fc60..f9b7140 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -475,6 +475,17 @@ Example: `5-0-1735344000000` = Medication 5, Blister 0, timestamp > Users upgrade their Docker containers but keep their existing DB. > The app must NOT crash if old columns are missing. +### ⚠️ MANDATORY for EVERY New Feature + +**Before implementing ANY feature that touches user data or settings:** + +1. **Check if new DB columns are needed** - Does the feature require storing new data? +2. **If YES → Follow ALL steps below** - Schema.ts + Drizzle migration + ALTER migration + NULL-safe code +3. **NEVER skip the ALTER migration** - This is the #1 cause of production 500 errors! + +**Common mistake:** Adding a column to `schema.ts` and forgetting the ALTER migration in `client.ts`. +The Drizzle migration only works for NEW databases. Existing production databases need the ALTER migration! + ### Schema Management with Drizzle Kit The database schema uses **Drizzle Kit** for migrations. There is a **single source of truth**: