You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6ed361c
Browse filesBrowse the repository at this point in the historyBrowse files
docs(skills): teach the seed modes the loader runs and that a deleted seed row stays deleted
The objectstack-data seeds reference called upsert the default and said
replace deletes every row first. The loader defaults to ignore
(create-only) and replace deletes nothing. The reference, its seed eval
and the data-modeling seed guide now say so, and teach that a boot or
organization replay does not re-insert a seed row a person deleted,
with seed-replayer { reseed: true } as the way to restore it.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J8VVAkA4qny8vRgP2NzRgs
docs(skills): the objectstack-data seeds reference now teaches the seed modes the loader runs: `ignore` is the default (create-only), `replace` deletes nothing (it inserts into a table the caller cleared), and `insert` duplicates on each replay. It also says that a boot or organization replay does not re-insert a seed row a person deleted, and that `seed-replayer` with `{ reseed: true }` restores it. The data-modeling seed guide teaches the same rule.
Copy file name to clipboardExpand all lines: content/docs/data-modeling/seed-data.mdx
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,7 +71,7 @@ customer has since edited.
71
71
72
72
| Mode | Behavior | Use Case |
73
73
|:-----|:---------|:---------|
74
-
|`ignore`|**Default.** Create-only: insert a record whose row is missing, leave an existing row exactly as it is | Business and starter data the customer owns once it is loaded |
74
+
|`ignore`|**Default.** Create-only: insert a record whose row is missing (unless a person [deleted it](#a-deleted-seed-row-stays-deleted)), leave an existing row exactly as it is | Business and starter data the customer owns once it is loaded |
75
75
|`upsert`| Create if new, and on **every** replay write each declared column back onto the matched row | Reference data the package must keep current |
76
76
|`insert`| Insert **every** record unconditionally — no existing-row check, so it **duplicates the table on each replay boot** ([#3434](https://github.com/objectstack-ai/objectstack/issues/3434)). Rarely what you want | Append-only rows loaded exactly once (never re-run) |
77
77
|`update`| Update only, skip if not found | Migration patches on existing rows |
@@ -153,6 +153,28 @@ check**, so a replayed `insert` dataset duplicates its table on each restart
153
153
It is almost never the right mode: leave `mode` unset (create-only), or declare
154
154
`upsert` for reference data, with a stable `externalId` instead. `os validate` warns on any `mode: 'insert'` seed.
155
155
156
+
### A Deleted Seed Row Stays Deleted
157
+
158
+
Each organization records which seed rows landed in it, by `externalId`, in the
159
+
platform object `sys_seed_landed_key`. When a person deletes a seeded row, the
160
+
next replay does not insert it again: an `ignore` or `upsert` dataset inserts a
161
+
missing row only if its key never landed in that organization. A row an upgrade adds to the seed has never landed, so it
162
+
is still inserted. A reference to the deleted row from another seed row is left
163
+
unwritten rather than reported as an error.
164
+
165
+
The record is honoured by the boot seed (`objectstack serve`, `os start`, so
166
+
every restart and upgrade), the per-organization replay, and the dev hot
167
+
reload. A row deleted before your runtime had this rule comes back once, on the
168
+
first replay after the upgrade, and stays deleted from then on.
169
+
170
+
To bring the deleted rows back on purpose, a host or plugin calls the
171
+
`seed-replayer` kernel service with `{ reseed: true }`:
172
+
173
+
```typescript
174
+
const replay =ctx.getService('seed-replayer'); // ctx: the plugin's context
Copy file name to clipboardExpand all lines: skills/objectstack-data/evals/hooks-security-seeds-datasources.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@
34
34
{
35
35
"id": 4,
36
36
"prompt": "Seed the `country` table for every environment; add demo `opportunity` rows (dev/test only) closing 45 days after install, owned by the installer. A nightly job advances `stage`; a seed replay must not reset it.",
37
-
"expected_output": "`defineSeed(Country, { externalId: 'code', mode: 'upsert', records })` for reference data; `defineSeed(Opportunity, { env: ['dev', 'test'], ... })` for demo rows — natural-key lookups, CEL values (`close_date: cel`daysFromNow(45)``, `owner_id: cel`os.user.id``), parents first; `columns: { stage: { applyOn: 'create' } }` so an `upsert` replay leaves the job-owned column.",
37
+
"expected_output": "`defineSeed(Country, { externalId: 'code', mode: 'upsert', records })` for reference data; `defineSeed(Opportunity, { env: ['dev', 'test'], ... })` for demo rows with no `mode` (the `ignore` default never writes a matched row, so a replay leaves `stage`) — natural-key lookups, CEL values (`close_date: cel`daysFromNow(45)``, `owner_id: cel`os.user.id``), parents first; on an `upsert` dataset, `columns: { stage: { applyOn: 'create' } }` leaves the job-owned column.",
0 commit comments