Skip to main content
The trail CLI provides commands for managing your TrailBase server, users, migrations, and more.

Installation

The trail binary is included in TrailBase releases:

Global Options

These options work with all commands:

Server Commands

Start Server

Start the HTTP server:
First Run: On first startup, TrailBase creates admin credentials and displays them in the terminal. Save these to access the admin UI at http://localhost:4000/_/admin.

Server Options

Migration Commands

Create Migration

Generate a new migration file:
The generated file is ready to edit:
traildepot/migrations/main/U1234567890__create_table_posts.sql
Migrations run automatically when TrailBase starts. No separate apply command is needed.

View Applied Migrations

Check which migrations have been applied:

User Management

Create User

Add a new verified user:
Users created via CLI are automatically verified and can log in immediately.

Change Password

Change Email

Verify Email

Manually verify a user’s email:

Delete User

Deleting a user cascades to all records with foreign keys to _user.id. This cannot be undone.

Invalidate Session

Force a user to re-login:
This increments the user’s session version, making existing auth tokens invalid.

Mint Auth Token

Generate an auth token for a user (useful for automation):
Use the token for API requests:

Import Users

Import users from Auth0 or other providers:

Admin Management

List Admins

Promote User to Admin

Demote Admin to User

You cannot demote yourself. Use another admin account or direct database access.

Schema Commands

Export JSON Schema

Generate JSON Schema for a table:
Output:
Pipe to a file for code generation:

Export OpenAPI Spec

Generate OpenAPI specification:

Email Commands

Send emails programmatically:
Email settings must be configured in traildepot/config.textproto or via environment variables.

Component Management

List Available Components

Show first-party WASM components:

Install Component

List Installed Components

Update Components

Update all installed first-party components:

Remove Component

Common Workflows

Development Setup

1

Start Server

2

Create Admin User

3

Create Schema

4

Generate Types

Production Deployment

1

Set Environment Variables

2

Run Server

3

Configure Reverse Proxy

Use nginx, Caddy, or similar to handle:
  • TLS termination
  • Request compression
  • Static file caching
  • Rate limiting

Database Backup

TrailBase automatically creates backups in traildepot/backups/. These are SQLite database files that can be restored by copying them to traildepot/data/.

Reset Admin Password

If you lose admin credentials:

Test Configuration

Environment Variables

Override CLI options with environment variables:

Configuration File

Main configuration file: traildepot/config.textproto Example configuration:
traildepot/config.textproto

Logging

TrailBase logs to:
  • traildepot/logs/trailbase.log - Main application log
  • traildepot/logs/access.log - HTTP access log
  • stderr - With --stderr-logging flag
View logs:

Debugging

Verbose Logging

Test Database Queries

Health Check

Systemd Service

Run TrailBase as a systemd service:
/etc/systemd/system/trailbase.service
Manage the service:

Docker

Run TrailBase in Docker:
Docker Compose:
docker-compose.yml

Next Steps

First App

Build your first application

Migrations

Learn about database migrations

Authentication

Manage users and auth

WASM Runtime

Extend with WebAssembly

Reference