Change the data model: $ARGUMENTS
Stored data lives in JSON files that already exist on teammates' machines and on the server, so every change must read old files without breaking.
Steps
- Read
src/lib/links/schema.ts,src/lib/links/store.tsanddata/seed.json. - Decide if the change is additive (new optional field with a default) or breaking
(rename, remove, new required field, type change).
- Additive: add the field with
.optional()or.default(...)tolinkSchema, and tolinkInputSchemaif users can set it. No version bump. - Breaking: bump the data file
versionliteral (e.g.1→2). Keep the old schema asdataFileV1Schema, and add anupgradeV1toV2(data)function instore.tsthatload()applies when it reads a v1 file. Never rewrite files on read; the nextsave()writes v2.
- Additive: add the field with
- Update
data/seed.jsonto the new shape. - Update the UI only if the task asks for it.
- Tests in
src/lib/links/store.test.ts:- The new field round-trips through
createLinkandlistLinks. - For breaking changes: write a v1 file into the temp data path and assert
listLinks()returns upgraded links, and that a followingcreateLinksaves a v2 file.
- The new field round-trips through
- Run
npm run checkandnpm run build. - In your summary, state whether the change was additive or breaking, and what happens to existing data files.