CLI Usage
The Sidequest CLI provides an easy way to manage database migrations and configuration for your Sidequest job queue system. It supports all backend drivers and offers interactive setup wizards.
Installation
Install the CLI globally to use it from anywhere:
npm install -g @sidequest/cliyarn global add @sidequest/clipnpm add -g @sidequest/cliThe CLI can be invoked using either sidequest or the shorter sq alias:
sidequest --help
# or
sq --helpQuick Start
Get started with three simple commands:
# 1. Configure your backend connection
sidequest config
# 2. Run database migrations
sidequest migrate
# 3. Start using Sidequest in your applicationCommands
sidequest config
Interactive setup wizard to configure your backend connection. This command will prompt you to:
Choose a backend driver:
@sidequest/postgres-backend@sidequest/mysql-backend@sidequest/sqlite-backend@sidequest/mongo-backend
Choose how to provide the connection string:
- Enter it manually for immediate setup
- Use an environment variable for secure deployment
Example session:
$ sidequest config
? Choose a backend: @sidequest/postgres-backend
? How would you like to provide the connection string? Use an environment variable
? Enter the name of the environment variable: DATABASE_URL
✅ Configuration saved to: /path/to/project/.sidequest.config.jsonsidequest migrate
Runs all pending database migrations to set up or update your Sidequest schema. This command:
- Creates the necessary tables for jobs and queues
- Sets up indexes for optimal performance
- Applies any schema updates for new Sidequest versions
$ sidequest migrate
🔷 Current Configuration:
Backend: @sidequest/postgres-backend
Connection string (from env): postgresql://postgres:password@localhost:5432/myapp
Running migrations...
✅ Migrations completed successfullysidequest rollback
Rolls back the most recent migration. Use this if you need to undo the last schema change:
$ sidequest rollback
🔷 Current Configuration:
Backend: @sidequest/postgres-backend
Connection string (from env): postgresql://postgres:password@localhost:5432/myapp
Rolling back last migration...
✅ Rollback completed successfullyConfiguration File
The sidequest config command creates a .sidequest.config.json file in your current directory:
Environment Variable Configuration
{
"backend": "@sidequest/postgres-backend",
"connection": {
"type": "env",
"varName": "DATABASE_URL"
}
}Direct Connection Configuration
{
"backend": "@sidequest/sqlite-backend",
"connection": {
"type": "direct",
"value": "./sidequest.sqlite"
}
}Connection String Examples
PostgreSQL
# Local PostgreSQL
postgresql://postgres:password@localhost:5432/sidequest
# Remote PostgreSQL with SSL
postgresql://user:password@db.example.com:5432/sidequest?sslmode=require
# PostgreSQL with custom port
postgresql://postgres:password@localhost:5433/sidequestMySQL
# Local MySQL
mysql://root:password@localhost:3306/sidequest
# Remote MySQL
mysql://user:password@mysql.example.com:3306/sidequest
# MySQL with SSL
mysql://user:password@localhost:3306/sidequest?ssl=trueSQLite
# Relative path
./sidequest.sqlite
# Absolute path
/var/data/sidequest.sqlite
# In-memory (testing only)
:memory:MongoDB
# Local MongoDB
mongodb://localhost:27017/sidequest
# MongoDB with authentication
mongodb://user:password@localhost:27017/sidequest
# MongoDB Atlas
mongodb+srv://user:password@cluster.mongodb.net/sidequestBest Practices
Development Workflow
Initialize your project:
bashcd my-project sidequest configSet up your database:
bashsidequest migrateVersion control: Add
.sidequest.config.jsonto your repository, but keep connection strings in environment variables for security.
Production Deployment
Use environment variables for connection strings:
bashexport DATABASE_URL="postgresql://user:password@prod-db:5432/sidequest"Run migrations as part of your deployment process:
bashsidequest migrateNever commit actual connection strings to version control.
Troubleshooting
Configuration File Not Found
❌ Could not read configuration file: /path/to/.sidequest.config.json
Run `sidequest config` first to create one.Solution: Run sidequest config to create the configuration file.
Environment Variable Not Set
⚠️ Environment variable DATABASE_URL is not setSolution: Set the required environment variable:
export DATABASE_URL="your-connection-string"Backend Driver Not Found
Backend driver "@sidequest/postgres-backend" not found or does not export a default class.
Make sure the driver package is installed (e.g., run "npm install @sidequest/postgres-backend").Solution: Install the required backend driver:
npm install @sidequest/postgres-backend