Administration

SQL Console

Run SQL queries directly against the AirTrail database.

The SQL console runs SQL statements against the AirTrail PostgreSQL database and shows the results in a table. It is meant for troubleshooting and one-off fixes that the interface does not cover.

The SQL console runs arbitrary SQL with the same database access as AirTrail itself. It bypasses every role and permission check. A single statement can read any user's data, change any record, or delete every table. Changes take effect immediately and there is no undo.

Who can use it

Using the console requires the tools.sql.execute permission, shown as SQL console under Security and tools in the role editor.

Neither built-in role includes it, so on a new instance only the owner can use the console. The owner can add it to a role under Settings → Roles, but anyone with it effectively has full control of the instance. See Roles and permissions.

Running a query

Before running anything that changes data, back up your database.

  1. Click Tools in the navigation dock. It is only shown to users who can use at least one tool.
  2. Choose SQL Console.
  3. Type a statement into the text box.
  4. Click Execute.

Rows returned by the statement are shown in a table with one column per result column. Statements that return no rows, such as UPDATE or DELETE, show No data. If the statement fails, the database error is shown instead.

Run one statement at a time. Each statement is committed as soon as it runs. To try a change safely, check it first with a SELECT using the same WHERE clause:

SELECT id, username, display_name FROM "user";

Table names follow the database schema in prisma/schema.prisma. Some names, such as "user", are reserved words in PostgreSQL and must be quoted.

Last updated on

On this page