db-defaults-generated
Installation
SKILL.md
db-defaults-generated (M6)
Defaults and generated columns are correctness placed at the source: a created_at DEFAULT now() is true for every writer, and a GENERATED ALWAYS AS column can never drift from its inputs. Pushing this logic into the app means each writer can get it wrong differently. This module is design-axis (Tipos category). It applies to engines supporting defaults/generated columns.
What it checks
- Timestamp defaults:
created_at/updated_atset only by application code (noDEFAULT now()/CURRENT_TIMESTAMP, noON UPDATE/trigger) — inconsistent across writers, missing on raw SQL inserts. - Derived value should be generated: a stored column computed from siblings (
full_name,total = qty*price,search_vector) kept in sync by app code rather thanGENERATED ALWAYS AS ... STORED— drift-prone (ties to M1 denormalization discipline). - Non-deterministic / wrong default: defaults that bake in a value that should be dynamic, or a default that masks a missing NOT NULL (e.g.
status DEFAULT 'active'hiding required intent), or aDEFAULT ''standing in for NULL. - Identity/sequence hygiene:
serialvsGENERATED ... AS IDENTITY; shared/incorrect sequence ownership. - Boolean/flag defaults missing, forcing three-valued logic where two was intended.
Axis & severity
- Axis: design; magnitude banded, never invented drift rates.
- Derived stored column maintained by app (drift risk): severity 3,
warn,fixable: proposed. - Missing
created_at/updated_atDB default: severity 2–3,warn,fixable: auto(additive default). DEFAULT ''/sentinel masking NULL semantics: severity 2,warn.- M6 holds no sev-5 cap; it shapes the Tipos category value.