Skip to main content

Table Operations

Operations that change a table's schema, such as renaming the table or adding, editing, or deleting a column, are made in the development environment. Each change is recorded as a migration in the table's migration history, and is later run in staging and production. See Migrations to learn more.

Available Actions in Each Environment​

ActionDevelopmentStaging and Production
Create or edit a table✅❌
Add, edit, or delete a column✅❌
Add, edit, or remove a foreign key✅❌
Write a SQL migration✅❌
Add, edit, or delete rows✅✅
Bulk upload or export data✅✅
Seed data with SQL✅✅

Deleting a table deletes it in every environment. See Delete Table.

Confirm a Schema Change​

Creating a table records its first migration, 0001, automatically. For any other change, such as editing a column or adding a foreign key, ToolJet shows a confirmation modal first:

  1. Make the change in development and save it.
  2. In the confirmation modal, review the Changes overview. If applications, modules, or workflows use the table, the modal also shows how many, for example 3 resources depend on this table. Expand it to see each one and its queries.
  3. (Optional) Enter a Title for the migration. If it's left blank, ToolJet generates a name, for example Add column "email".
  4. (Optional) Click Add migration to add a SQL step that runs right after the change, such as filling a new column with values. This option isn't available when dropping a column or removing a foreign key.
  5. Click Run in development.
Schema change confirmation modal with Run in development highlighted

The change is applied to the development table and added to the table's migration history with the next number, for example 0002. A SQL step is recorded as its own migration, right after the change.

info

If the change is applied but the SQL step fails, ToolJet shows Schema change applied; SQL step failed with the database error. Fix the SQL and click Run in development again.

Search Table​

Open the Search bar by clicking on the Search button and search for a table in the ToolJet database by entering the table name.

ToolJet database

Rename Table​

To rename a table, click on the kebab menu icon on the right of the table name and then select the Edit table option. A drawer will open from the right from where you can edit the table name.

ToolJet database

Add New Column​

To add a new column to a table, either click on the kebab menu icon on the right of the table name and then select the Add new column option or click on the + button present at the end of the column header.

A drawer from the right will open up where you can enter the details for the new column:

  • Column Name: Enter a unique name for the new column, serving as its key identifier.
  • Data Type: Choose the appropriate data type for the column from the available options. For more information on data types and their associated constraints, see the Supported Data Types and Permissible Constraints per Data Type sections.
  • Default Value: Specify any default value that should be assigned to the column. Optionally, users can leave this field blank. When a table contains rows and NOT NULL is applied to one of its existing or new columns, specifying a default value becomes compulsory.
  • Foreign Key Relation: Click on the toggle to add a foreign key relationship to the column. This will open a menu where you can select the target table and column to reference.
ToolJet database

Export Schema​

The export schema option allows you to download the selected table schema in a JSON file. This does not export the table data or the relationships.
While exporting the app, you can choose to export the app with or without a table schema connected to the app.
To export the table schema, click on the three vertical dots icon on the right of the table name and then click on the Export option. A JSON file will be downloaded with the table schema.

ToolJet database

Delete Table​

To delete a table, click on the three vertical dots icon on the right of the table name and then click on the Delete option. A confirmation modal will appear, click on the Delete button to delete the table.

ToolJet database

Deleting a table permanently deletes it, and its data, in every environment. Tables can be deleted only in development.

ToolJet blocks the deletion if:

  • A query in an application, module, or workflow uses the table, including queries in drafts and older versions.
  • Another table has a foreign key that references it.

When the deletion is blocked, a dialog such as Dependent queries found or Referencing tables found lists what's blocking it. Remove those references, and then delete the table.

Delete table modal explaining that the table is used by an application

Edit Column​

To edit a column, click on the kebab menu on the column name and select the option to Edit column. Saving the change opens the schema change confirmation.

ToolJet database

Change a Column's Data Type​

The Data type dropdown in the column editor lists only the types the column can be converted to.

FromToWhat Happens
intbigint, floatApplied directly.
bigintfloatApplied directly.
int, bigint, float, booleanvarcharToolJet fills in the SQL step. Every value converts.
varcharint, bigint, float, booleanToolJet fills in the SQL step and checks existing values first.
varcharjsonbToolJet fills in the SQL step. Values can't be checked in advance.
bigintintToolJet fills in the SQL step and checks that values fit the int range.

When ToolJet checks existing values, it shows how many rows can't be converted. For conversions from varchar, click Show rows to see them.

warning

The value check covers only the development table. A row in staging or production that can't be converted stops the migration when it runs there. Check those rows before running the migration, for example with a filter on the table in that environment.

If the column has a default value and ToolJet fills in the SQL step, the step removes the default, because the old default can't be converted. To keep a default, add a new one in the same SQL step.

The type of a primary key, an auto-incrementing (serial) column, or a column in a foreign key can't be changed. For these, and for conversions that aren't listed, such as float to int or any conversion to a date, write a SQL migration.

Delete Column​

To delete a column, click on the kebab menu on the column name and select the option to Delete. You cannot delete a column if it is being used as a primary key. You will have to remove the primary key constraint from the column before deleting it.

ToolJet database