{"success":true,"name":"version-and-migrate-your-data-shape-the-db-outlives-every-co","description":"Changing the shape of stored data in a project that already has real records","category":"ai-brimind","path":"ai-brimind/version-and-migrate-your-data-shape-the-db-outlives-every-co/SKILL.md","file":"SKILL.md","content":"---\nname: version-and-migrate-your-data-shape-the-db-outlives-every-co\ndescription: \"Changing the shape of stored data in a project that already has real records\"\n---\n\n# Version and Migrate Your Data Shape: The DB Outlives Every Code Change\n\n## When to use\nChanging the shape of stored data in a project that already has real records\n\n## Example request\nNew required field 'phoneVerified' added to the user schema → all existing users lack it, and every screen assuming it exists breaks on old accounts; old data does not update itself. Field renamed from 'fullName' to 'name' in the code only → new records use 'name', old ones still carry 'fullName', and half the app shows blanks; a rename in code is a migration in the DB. Status values change from 'open/closed' to 'active/archived/deleted' → old rows still say 'open' and match no logic branch; the old vocabulary must be translated, not abandoned. Brand-new collection with zero records → change the schema freely; migration discipline is for data that already exists.\n\n## Instructions\nAct as a data guardian who knows the database is the only part of the system that remembers the past — code deploys replace each other, but every record ever written under an old shape is still sitting there. Before changing any stored data shape in a project with real records, do this: (1) State the change precisely: adding a field, renaming one, changing allowed values, or restructuring (splitting/merging). Each has a different blast radius. (2) Ask the key question out loud: 'what do the EXISTING records look like after my code change?' — because the answer is always 'exactly like before'. Then trace what your new code does when it meets such a record: crash, show blank, or misbehave silently? If you cannot answer, read the code paths that consume the field before touching anything. (3) Pick a deliberate strategy and name it: write a one-time migration script that updates all old records to the new shape (clean, best when you can run it), OR make the code tolerate both shapes with a default ('phoneVerified missing means false') — a conscious fallback, not luck. For renames and value changes, migration is almost always the honest answer; tolerating two names for the same thing forever is how codebases rot. (4) Make the migration itself safe: run it on a copy or backup first, make it re-runnable without double-applying (check before write), and log how many records it touched so you can verify the count matches expectations. (5) New project, empty collection? Say so and skip the ceremony. Only proceed once you can describe what BOTH an old record and a new record look like after your change, and why every code path handles the pair — 'it works on the records I created today' ignores the only records that actually matter: the old ones.\n\n## Metadata\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #195\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}