Data

Columns and relationships

Columns define what each row of a custom table stores. Relationship columns link a row to a row in another table, such as the user who owns it.

Add columns

1

Open the table editor

Go to Database, then Custom Tables, click Edit Table and open the Table Structure tab.

2

Add a column

Click Add Another Column.

3

Describe it

Fill in Column Name and Data Type. Turn on Required if every row must have a value, and add a Default value if you want one.

4

Save

Click Save & Commit to Database. The change runs on your database right away.

The editor starts with the columns the table already has. Add new ones below them.

Data types

String

Short text, such as a name or a status.

Text

Longer text, such as a description.

Int

Whole numbers.

Float

Numbers with decimals, such as a price.

Boolean

True or false.

Date

A date or a moment in time. It accepts now() as a default.

Json

Structured data stored as JSON.

Relationship

A link to a row in another table. See Relationships below.

Use Date for dates and timestamps. Saving a DateTime column currently fails, and nothing is applied.

Names, required and default values

Column Name

Letters, numbers and underscores. Names are stored in lowercase. id, uuid, createdat and updatedat are reserved.

Required

Every row must have a value in this column.

Default value

Written as a raw database value: 0, true, text in single quotes such as 'draft', or now() for the current time.

There is no unique option. If a value must be unique, check for it in your function before inserting.

Relationships

A Relationship column links each row to one row of another table. The target can be another custom table, or the system tables for users, files or admins.

Choose the Target Table, then choose what happens when the linked row is deleted in On Delete.

CASCADE

Deleting the linked row also deletes this row.

SET NULL

Deleting the linked row clears the link and keeps this row.

SET DEFAULT

Deleting the linked row sets the column back to its default value.

RESTRICT / NO ACTION

The linked row cannot be deleted while rows still point at it.

A relationship is not followed automatically. To read the linked row's fields, add a JOIN in your custom query that matches this column to the other table's id.

Changing a table that holds data

The editor keeps track of each existing column, so renaming a column keeps its data.

Removing a column deletes it and all of its data as soon as you save. Changing a column's type can also fail or lose data. Check twice before you save a table that is in use.

You can add new columns at any time. Existing rows get the default value, or stay empty.

Rename with care: every query that uses the old name must be updated.

If a save is refused, add new columns one at a time to find the one the database rejects.