Check stored forms before the next major
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, 19, refuses those three shapes at
every write door (422, naming the stack's forms:) and serves no form from
them. 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, os migrate protocol --to 19 --apply --yes
(below).
os migrate stored-forms
os migrate stored-forms --jsonIt 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. The rows the server serves behind it at that package 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. A row of a .custom package that the deployment holds as code stays in that package as its own form, whether or not the package ships that name. Where the server today serves such a row at one other package's address, it moves as a row of that package does, into that package's .custom package as a declared override. The rows the server serves behind the moved row at that package 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. Where another package serves that row with a public link and would move it, the row holds the upgrade at every one of those packages instead: both rows stay. Both rows stay as stored at every other package too: where either stands behind a row another package would move or remove, that move or removal holds the upgrade instead of folding or removing it. When the row served is one whose form content cannot be read, the form waits on that row, which holds the upgrade (below). A form no door serves today is left in place by the upgrade too, whatever package its row is bound to: the server serves no form of that name at the address the report names, so nothing of it moves, its rows stay as stored there, and the address keeps answering as it does today. A form that is switched off is not one of these: the server serves it closed, and it moves with its switch. |
| holds the upgrade | The row cannot be moved. The report repeats the reason and the action. |
For each form, the report asks the server whether it serves a form of that
name today at the address the report names it at: a package, or the
environment. For a form stored with no package, the environment's address
covers every place the server serves it, under a package that ships only a
list of that name included. A form it does not serve there is left in
place where the table would move it, and also where the move would hold the
upgrade because its .custom package cannot be ensured or its destination is
sealed: the upgrade never moves a form into service.
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. Where the server today serves one
row at two packages' addresses of one app that would both move it, or two
rows would move into one slot of the app's .custom package (a row the
.custom package already holds of that name among them), each such row
holds the upgrade: a
.custom package holds one row of a form's name, so neither address can be
given a destination. Where the server serves one row at several packages,
of one app or of several, and those packages would not all move it or all
remove it (one moves or removes it, another leaves it in place or holds),
the row holds the upgrade at each of them too: moving or removing a row
takes it from every package that serves it. Nothing moves, and every
address keeps answering as it does today. The row is named once, with every
address it is read at. A row every package that serves it would remove is
removed, and one every package leaves in place is left in place. A row that
holds the upgrade is not folded into another row: where it stands behind a
row that moves, the report names it apart.
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.
What the upgrade command writes
The major's upgrade command is os migrate protocol --to 19. Without
--apply it previews: it runs the same check, prints the same report, and
writes nothing. It exits 0 when the deployment can switch and 1 when a row
holds it, with each holding row and the action for its cause; take each action
on the release you are running, then run it again.
os migrate protocol --to 19 # preview: writes nothing
os migrate protocol --to 19 --apply --yes # move the stored forms, check again, switch
os migrate protocol --to 19 --jsonIt composes the deployment as os serve does, so pass the same --preset,
--dev and --database-url. --apply is refused while another process holds
a SQLite database file. It asks for confirmation on a terminal; in a script,
pass --yes, because a run without it writes nothing and exits 1.
With --apply, the command runs the same check first, and writes only when
no row holds the upgrade. If one row holds it, nothing is written: every
stored row stays byte for byte as it is, both public doors answer as they do
today, and the deployment stays on the release it is running.
Otherwise, the .custom packages the moves land in are created first,
through the one path that creates them, before any row is written. They stay
if the run fails: an empty .custom package changes no answer, and the next
run reuses it. Then, in one transaction:
- Each form that moves is written as a form row at its destination, with its body as stored. A form whose folded row switched it off is written switched off, its link kept. Each written row is read back before anything else changes.
- Then the old rows go: a view item row is deleted; a stored view container is saved again without the form it held, its lists and any form it still keeps byte for byte as they were. A container left with nothing in it is deleted.
- Each internal record form listed as will be removed is deleted the same way, and the report carries its body.
If any step fails, the transaction rolls back and every stored row stays as it was.
The upgrade command writes only on a database that can roll a transaction
back. Where the database's driver cannot, the command refuses before it
changes anything (no .custom package is created either) and names the
driver. Run the upgrade against a database whose driver supports
transactions, or stay on the release you are running. os migrate stored-forms still reports what the upgrade would move, and says on such a
database that the upgrade's run will be refused. A run with nothing
to move or remove is not refused.
A form left in place is not touched, nor is a draft. Run the command again and it finds nothing left to move.
After the transaction commits, the command runs the check once more. Only
when that check finds the deployment can switch, with nothing left to move or
remove, does it record the switch: a verified sys_migration row,
adr-0159-form-type-switch. A run the check holds records nothing, that row
included. The row is the switch's record, and a protocol-19 server reads it at
start: os serve (and so os dev and os start) refuses to start on a
database an earlier release created until the row is there and verified, and
its refusal names this command. A database with no stored form runs the
command once too: it finds nothing to move and records the switch. A database
the server creates from empty is given the record at its first start, since it
stores no form.
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. |
Two rows would land in one slot of an app's .custom package, or one row that several packages serve would not be treated alike by all of them | No one, on this release | No exit from it was measured: the deployment stays on the release it is running, and every address keeps answering as it does today. Where the row is read at two packages of one app that would both move it, the app shipping the form from one of those packages only lets it be read at that package alone. Where the row waits on another hold of its own, it takes that hold's row above. |
Another package ships a form item under the form's name, so the row would be written over a managed package's item, which is sealed | The author of the package that ships it | No exit from it was measured: the deployment stays on the release it is running, and the row keeps working as it does today. |
| 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. The row holds the switch, and a protocol-19 server does not start on a database whose switch is not recorded, so the repair is made on the release you are running. |
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.