Tables that change without losing a single row.
Declare a table and deploy it. Volvel works out the change: a new column is added, a renamed one keeps its data, a removed one is set aside. Row rules decide who sees what, and the database itself holds every caller to them.
- Postgres
- twelve column types
- row rules
- never drops data
Declare it once.
A table is a definition: its columns, what each holds, and who may read or change its rows. Scripts and apps that use it get its types, so a wrong value fails to compile before the database ever refuses it.
- A choice column offers its values in colour, and the database refuses any other.
- A reference says what happens when the row it points to is deleted: refuse, empty the column, or delete along with it.
- Add a description to a column, and it shows on the column's heading wherever the table is read.
export const loans = defineTable({
path: "loans",
display: "number",
columns: {
number: column.text({ required: true, unique: true }),
status: column.enum(
["out", { value: "returned", label: "Returned", color: "green" }],
{ required: true, default: "out" },
),
extras: column.enumList(["charger", "case"]),
device: column.reference(devices, { onDelete: "set_null" }),
due_on: column.date({ description: "When it must be back." }),
},
}); From the SDK guide. The same table can be kept as a YAML file and edited in the console.
A deploy never drops data.
The bundle carries each table's definition. On deploy, the platform compares it with what the workspace has and applies the difference.
- Rename a column, a choice value or the table itself with
renamedFrom, and the rows come with it. - A column or value that leaves the definition is retired: hidden, with its data kept. Deleting it for good is a separate action, in the audit log.
- Dev and production hold their own rows. Promotion carries the change to the table, never the data in it.
Twelve column types.
Up to two hundred columns a table, each required, unique or given a default as you choose.
| Type | Holds |
|---|---|
| Text, integer, number, boolean | The everyday values. A long text opens in a field that grows with it. |
| Date, timestamp | A day, or a moment. Charts and totals can group them by day, week, month or year. |
| Choice | One value from a list, each with a label and a colour. A value taken out of the list stays on the rows that hold it and isn't offered again. |
| List of choices | Several values from a list, kept in order, each checked by the database. |
| Reference | A row of another table, shown by name and picked by typing. Indexed, with a rule for when that row is deleted. |
| File | A file in the workspace's storage. A replaced or removed file stays in the row's history for as long as the tenant keeps its audit log. |
| JSON, UUID | Structured data shown indented, and identifiers from other systems. |
Rules the database keeps.
A table says who may read and who may change its rows. The rule is compiled into Postgres, so it holds for the console, every app, every script acting for someone, and every SQL query, with nothing to remember in each.
- Open to everyone who may read the table, kept to each row's owner, or matched by rules.
- A rule matches a column against the person asking, their groups, or an attribute of theirs, such as a client number.
- Who is asking is passed to the database with a signature it checks, so nothing running on that connection can claim to be someone else.
export const appointments = defineTable({
path: "appointments",
// …columns…
policy: {
rules: [
// Staff of a clinic: that clinic's visits, to read and change.
{ allow: "all", when: { column: "clinic", in: "groups" } },
// A pet owner: their own visits, to read.
{ allow: "read",
when: { column: "client_code", equals: { attribute: "client_id" } } },
],
},
}); From the Fernhill example: three clinics and their pet owners on one table.
Working with the rows.
- A grid to work in
- Browse and edit rows in the console with the header pinned. Drag any column to any place, and lock the first one or not.
- Find a referenced row by typing
- The picker asks the server for matches, so it finds a row however far down the table it is.
- A row API for everything else
- Filter with and, or and nine comparisons, sort, page by cursor, and total, from scripts, apps and the HTTP API alike.
- Indexes where you need them
- Name the columns your screens and queries filter on, up to five per index, and the deploy builds the index.
- Where it's kept
- A Postgres schema of the workspace's own, or a Postgres database of the tenant's own when its data must live apart.
- Moves keep everything
- Give a table a new path and it keeps its rows, history and access. The old address leads to the new one for 90 days.
Related
Keep the data close to the work.
Declare a table, deploy it, and change it as often as you need.