Skip to content

update_table

Changes a table this site already has: what it collects, what it is called, who may write and read it, which rows are published, and how long it keeps its rows. Typed inside bash, where help update_table prints the same.

Usage: update_table HANDLE [options]
Changes a table this site already has: what it collects, what it is
called, who may write and read it, which rows are published, and how
long it keeps its rows.
Every change but `publication` is written into tables/<handle>.json
on `branch`, and nothing changes until merge_branch: merging then
moves the rows to the new shape, and the answer's `tables` says how.
The write is judged with the branch's pages, and refused, saying
where, if they would no longer work with the table: change those
pages on the branch first, then send the call again.
`fields` is sent **whole**. A field renamed says the name it had, so
every row keeps its value; a field dropped without one has its values
removed by a merge that needs the owner's approval, which the Vizitka
app cannot take yet.
`vzk/tables` says the rest.
`publication` is a setting of the table the site has, live at once:
send it on its own, without `branch`.
`dry_run` writes nothing and answers what the call would do.
`code_access` is what this site's code, the functions its forms run,
may do to the table: `count` its rows, `insert` a row. A page that
shows a count, or changes with it, tells every visitor how many rows
the table holds. Code cannot add rows to a table visitors can read.
`read`, `update` and `delete` are written only where the site may
give them, and the merge then waits for a person to approve it. On a
frozen site, whose branches cannot be merged, a call that only takes
grants away is sent without `branch` and goes live at once.
A reserved table keeps the contract `get_site` states on it, and a
definition that breaks it is refused naming what reads it. Read
`vzk/tables` first.
Options:
--handle TEXT (required)
The table's handle, as get_site lists it.
--fields JSON ... (give the flag again for each)
The whole shape of one row, replacing what is there, at most 100 fields. Written on the branch, and the table and its rows change when it is merged. A reserved table has to keep the shape its screen needs, and a role dropped here is a role the platform reads off no field of this table.
--name TEXT
What the owner sees this table called: at most 100 characters, with no line break or other control character.
--publication JSON
Which rows may appear publicly. Set field to null for all rows, or name a declared date field (today or earlier) or boolean field (true). Null restores the default: posts and portfolio use published_at; other tables show all rows. Changes are live at once without editing rows. Table read access still applies.
--keep TEXT
How long the table keeps a row, as a whole number of days from 1 to 36500: "90 days" or "1 day". Rows older than that, counted from the day each was added, are removed from the table once a day, never sooner than a day after the setting is saved or changed, and cannot be brought back by the owner or by an agent, so ask the owner before setting it. Taken only for a table that is `readable_by: public`: any other's is the owner's to set, and the Vizitka app cannot set it yet. Null keeps every row, which is the default.
--writable_by owner|public
Who may add a row. Written on the branch, and live when it is merged.
--readable_by owner|public
Who may read a row. Written on the branch, and live when it is merged. `owner` is refused while a page on the branch reads the table, the table's own page among them: delete or change those files on the branch first. Every row's address goes with the table's own page, so say so to the owner before deleting it.
--code_access count|insert|read|update|delete ... (give the flag again for each)
What this site's code may do to the table, sent whole and replacing what is there. Written on the branch, and live when it is merged. On a frozen site, a call that only takes grants away is sent without `branch` and goes live at once. A count on a page tells visitors how many rows the table holds. An empty list takes every grant away.
--branch TEXT
Needed for any change but `publication`: the branch to write tables/<handle>.json on. Left out on a frozen site, where taking grants away goes live at once.
--message TEXT
What the change is, in a line. Defaults to naming the files.
--dry_run (a flag)
Write nothing, and answer what the call would: the file as it would read, what the check would refuse, and what merging would do to the table. Without `branch` it is tried against main. Default false.
--json OBJECT
Every argument at once, as one JSON object; --json - reads it from stdin.