Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changeset/37111-stored-forms-census.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@objectstack/metadata-protocol': patch
'@objectstack/cli': patch
---

feat(cli): `os migrate stored-forms`, the read-only census and precheck of the stored-form ceremony (ADR-0159 D7)

Clause-②: yes
Metadata-protocol: none

The next protocol major stops reading the three old shapes of a form (a view container's `form`, a `formViews` entry, a `viewKind: 'form'` item). Its upgrade command moves the stored rows that still hold one, in the same run that switches to the major, all or nothing. `os migrate stored-forms` shows that outcome before the upgrade and writes nothing: for each form name at each package that can serve it, whether the row is kept, moved (into the base's paired `.custom` package as a declared override, into a writable package's own form row, or into the environment), folded into the served row, removed as an internal record form, or left in place; and whether the upgrade can switch, naming each row that holds it (its pair cannot be ensured, or its form content cannot be read) with the action for its cause. A row bound to a read-only package that ships no form of its name moves into that package's paired `.custom` package as a form of its own. Old-shape drafts are listed: they are neither moved nor deleted, and cannot be published after the upgrade. A row read at several packages is named at each, and is removed only where it is an internal record form at every one of them. A withdrawal a folded row carries that no layer reads today is named newly closed.

`listStoredFormsOf(protocol)` answers the census over a protocol instance; it and its types are exported (`StoredFormCensus` and the shapes it names). The start-up message for a stored view whose form content cannot be read now names the command. `orderedFormRowsAt` is the served-row order the effective `form` read already used, now read by the census too; the read serves what it served.

The operations page is `content/docs/deployment/stored-forms-upgrade.mdx`.
2 changes: 2 additions & 0 deletions content/docs/deployment/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,7 @@ written.
| `os migrate security-catalog-overlays --apply` | **Refuses** likewise — it deletes `sys_metadata` rows, and a live process saving metadata is exactly the collision |
| `os migrate packageless-overlays --apply` | **Refuses** likewise — it moves `sys_metadata` rows into each base's pair |
| `os migrate stored-references bind` | **Refuses** likewise — it writes one row's package column |
| `os migrate stored-forms` | Warns and continues — it is read-only |

The check applies to SQLite only: Postgres and MySQL take their own server-side
locks. Only same-user processes are visible without elevated privileges, and a
Expand Down Expand Up @@ -1564,6 +1565,7 @@ where the data lives.
| `os migrate meta --stored` | Replay the metadata conversion chain over this deployment's `sys_metadata` rows and rewrite the ones still carrying a pre-protocol shape. Hygiene, not a gate — nothing depends on it having run |
| `os migrate security-catalog-overlays` | List the environment-wide permission-set and position rows (the legacy plurals `permissions` / `positions` included) stored over a name a configured package holds — the rows a v18 cold boot refuses — each with the package that holds its name; `--apply` deletes them, one history tombstone per row. Run it before the first v18 boot, with the flags and environment the deployment boots with: the platform security plugin's sets are held only where `os serve` composes it (an auth secret set, and the `auth` tier on), and the step takes `serve`'s `--preset` and `--dev` with `serve`'s meaning. Adopts nothing; exits 1 while it lists a row |
| `os migrate packageless-overlays` | List the package-less view, dashboard, report, translation and email-template rows stored over a name exactly one installed package ships — the customizations Setup saved before ADR-0146 D11 closed that write — and with `--apply` move each into that package's paired `<base>.custom` (created when absent) as a declared override, `basedOn` the base's installed version; the package-less row is deleted only after the moved one reads back as served. A name no package ships is environment metadata and is not touched; a name several packages ship, or one the pair already holds a row of, is listed and left with the reason. So is a view container (`list`, `listViews`, `form`, `formViews`): only a single view declares an override, so it is listed `cannot_declare` and never attempted, with the way out — save each of its views into the pair as a single view, then delete the container row. Takes `serve`'s `--preset` and `--dev`. Idempotent: a second run moves nothing. Run it once after upgrading |
| `os migrate stored-forms` | Read-only: list what the upgrade to the next protocol major does with every stored row that still holds a form in an old shape (a view container's `form`, a `formViews` entry, a `viewKind: 'form'` item) — kept, moved, folded, removed as an internal record form, or left in place — and whether that upgrade can switch, naming each row that holds it (its `.custom` pair cannot be created, or its form content cannot be read) with the action for its cause, and listing the old-shape drafts that cannot be published after the upgrade. No `--apply`: the move runs only inside the upgrade command. Takes `serve`'s `--preset` and `--dev`. See [Check stored forms before the next major](/docs/deployment/stored-forms-upgrade) |
| `os migrate stored-references` | List the stored references the upgrade left naming no package because the one resolution rule (ADR-0150 D3) refuses them: a user's permission-set assignment, an audience-binding suggestion, a managed sharing rule, a queue membership, an open approval request, a paused flow run, a flow credential, a flow dispatch key, a connector connection, an assignment cursor or a legacy email template whose name more than one package holds, each with its row id and every candidate by its qualified address (`namespace/name`). A suggestion a package wrote naming an environment-authored permission set, or one held only outside the package's declared dependencies, is listed with the fix and is never bindable. Also lists the packaged fields whose picklist the rule refuses (served with no options) the names two packages held before the one-holder rule, and each installed package whose namespace spells a literal segment of the address grammar (`actions`, `connectors`, `global`, `hooks`, `oauth`, `runs`, `trigger`): the boot keeps it with one warning, its items are read with `?package=ID`, and only a rename of its namespace gives them qualified addresses at the door that reads the literal (for `runs` that door is the inbound hook alone, reached at its bare address until then). Read-only, and `--json` prints the same bytes on every run. Run before the release's first boot, it reads a table that has no package column yet as nothing bound yet, lists the rows that boot's backfill will leave unbound, and says so once; it adds no column. A table this composition does not carry (automation, approvals) is named, not skipped: compose as `os serve` does, with `--preset`/`--dev`. Then `os migrate stored-references bind --table T --id ID --package P` writes the package you chose into that one row: it asks the rule again first and refuses, writing nothing, when the row is already bound, now resolves on its own, or the package is no longer a candidate (a stale report), and refuses (`duplicate`) a bind the table's unique key refuses because a row bound to that package already holds the key, such as a connector connection the instance already has in that organization. Each bind leaves a `sys_audit_log` row; a second run writes nothing. Confirm with `--yes` |
| `os migrate duplicates` | Report business identifiers already minted twice across the organization partitions, and the rows blocking the boot-time NULL-safe index tightenings — a read-only inventory as JSON on stdout. Renumbers nothing and writes no row and no schema; run it before the boot-time tenancy repair, which overwrites part of the evidence |

Expand Down
1 change: 1 addition & 0 deletions content/docs/deployment/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"backup-restore",
"tenancy-modes",
"seed-tenancy-repair",
"stored-forms-upgrade",
"single-project-mode",
"marketplace-handbook",
"publish-and-preview",
Expand Down
78 changes: 78 additions & 0 deletions content/docs/deployment/stored-forms-upgrade.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
title: Check stored forms before the next major
navTitle: Stored Forms Check
description: What `os migrate stored-forms` reports about the forms your database still stores as views, what the upgrade to the next protocol major will do with each, and how to clear a row that holds the upgrade.
---

A form used to be stored as a view: a view container's `form`, a `formViews`
entry, or a view item with `viewKind: 'form'`. Forms are now their own
metadata type, and the next protocol major stops reading those three shapes.
Whatever your database still stores in them is moved by the major's upgrade
command, in the same run that switches to the major. The move and the switch
are all or nothing: if one stored row cannot be moved, the upgrade does not
switch, and the deployment stays on the release it is running.

`os migrate stored-forms` shows you that outcome before you upgrade. It writes
nothing, and it has no `--apply`: the move is reached only from the upgrade
command.

```bash
os migrate stored-forms
os migrate stored-forms --json
```

It composes the deployment the way `os serve` does, so pass the `--preset`
and `--dev` flags the deployment boots with, and `--database-url` (or
`$OS_DATABASE_URL`) for the database. The boot is read-only. The command exits
`0` whenever the check ran; `canSwitch` in the `--json` output says whether
the upgrade would switch.

## What it reports, per form

A form is reported at each package that can serve it: a read-only package
that ships it (an installed app, or a package your code provides), a writable
package of your own, or the environment itself when no package ships it.

| Outcome | What the upgrade does |
|---|---|
| **kept** | The form is already stored as a form. Older rows of the same form fold into it. |
| **moves** | The row moves to a form row, with its body as written: into the package's paired `.custom` package as a declared override for a read-only package, into the package itself for a writable one, or into the environment. An override already stored in a `.custom` package keeps its package and the version it is based on. A row bound to a read-only package that ships no form of that name, or an override of a package that ships none, moves into that package's `.custom` package as a form of its own, with no override declared; its public address answers as it does today. Older rows of the same form fold into it. |
| **will be removed** | The row is an internal record form: a create or edit form with no public link that no action opens, over nothing that has a link. New and Edit follow the object's field groups instead, and the report says whether the object declares any. A row bound to no package is read at every package that ships its form: it is removed only when it is an internal record form at each of them, and moves at each of them otherwise. An older row behind the removed one goes with it, unless another package serves that row: the report then names it as not removed, with what happens to it there. |
| **left in place** | Nothing moves. The row served for the name carries no form (a list stored over it, alone or with older form rows behind it), or an internal record form is served ahead of a row with a public link and is not removed because of it. Every row of the name stays as stored, and the address keeps answering as it does today. When the row served is one whose form content cannot be read, the form waits on that row, which holds the upgrade (below). |
| **holds the upgrade** | The row cannot be moved. The report repeats the reason and the action. |

A list stored behind the row served for a form is not part of it: the upgrade
leaves it as stored, and the report says so. When a row is read at more than
one package, the report names it at each, with what the upgrade does there.

When several rows of one form are stored (an override in the `.custom`
package, a row bound to the package, a row bound to no package), the body
kept is the one served today. A folded row carries one thing: if it switched
the form off (its link kept, `enabled` or `allowAnonymous` set to `false`), the
kept form keeps its link and is switched off too. When the folded row was one
that nothing reads today, that closes a form that is open today. The report
marks it **NEWLY CLOSED**, with the kept form's address. Switch it on again in Setup after
the upgrade if it should stay open.

A row that declares a public link, or that stands over a form that declares
one, is never offered for deletion. Deleting such a row would open a form
that is closed today.

## Clearing a row that holds the upgrade

| Cause | Who can clear it | What to do |
|---|---|---|
| The paired `.custom` package cannot be created: another package sits under its id or holds its namespace, or the app that carries the package is not installed | The administrator | Make the fix the quoted refusal names on the release you are running, then run the check again. |
| A `.custom` package an earlier version created for one package of the app holds the namespace | No one, on this release | The row holds the upgrade until that package is re-identified as the app's `.custom` package (ADR-0146 D3, merge question 12), and no command on this release does that. The row keeps working as it does today meanwhile. |
| The app declares no namespace, or an invalid one; its version is not SemVer; or the package belongs to several apps and its namespace picks none | The app's author | The deployment stays on the release it is running until the app ships a version without the cause. The row keeps working as it does today meanwhile. |
| The package is a kernel package, which has no `.custom` package in this version | The platform maintainers | Report it before upgrading. |
| The stored view's form content cannot be read | The administrator | Save the view again with its form content repaired (a `form` or `formViews` entry that is an object), then run the check again. On the release you are running, both public doors answer for the row as they do today. On the next major its links close, and that server's start-up log names each such row and points to this command. |

## Also listed

- **Drafts**: a draft view with form content in an old shape is neither moved
nor deleted. After the upgrade it cannot be published, so publish the drafts
you want to keep before upgrading. A form that moves names its draft, which
stays behind as stored.
- **Shared addresses**: a public address that two form names declare, such as
a retired form and the one that replaced it.
Loading
Loading