Database Configuration¶
Configure the storage backend for workflows, executions, and credentials.
Supported Backends¶
| Backend | Use Case |
|---|---|
| SQLite | Development, single-node |
| PostgreSQL | Production, multi-node |
SQLite (Default)¶
Zero-dependency local storage:
| Setting | Default | Description |
|---|---|---|
sqlite.path |
~/.m9m/data/m9m.db |
Database file path |
CLI Override¶
Benefits¶
- No external dependencies
- Simple backup (copy file)
- Good for development
- Sufficient for single-node production
Limitations¶
- Single writer (no concurrent writes)
- Not suitable for clustered deployments
PostgreSQL¶
Production-grade relational database:
database:
type: "postgres"
postgres:
host: "localhost"
port: 5432
database: "m9m"
user: "m9m"
password: "changeme"
ssl_mode: "disable"
max_connections: 25
max_idle_connections: 5
connection_lifetime: "5m"
Connection URL¶
Alternatively, use a connection URL:
database:
type: "postgres"
postgres:
url: "postgres://user:password@localhost:5432/m9m?sslmode=require"
CLI Override¶
Settings¶
| Setting | Default | Description |
|---|---|---|
host |
localhost |
Database host |
port |
5432 |
Database port |
database |
m9m |
Database name |
user |
m9m |
Username |
password |
- | Password |
ssl_mode |
disable |
SSL mode |
max_connections |
25 |
Max open connections |
max_idle_connections |
5 |
Max idle connections |
connection_lifetime |
5m |
Connection max lifetime |
SSL Modes¶
| Mode | Description |
|---|---|
disable |
No SSL |
require |
SSL required, no verification |
verify-ca |
Verify server certificate |
verify-full |
Verify certificate and hostname |
Create Database¶
CREATE DATABASE m9m;
CREATE USER m9m WITH PASSWORD 'your-password';
GRANT ALL PRIVILEGES ON DATABASE m9m TO m9m;
Environment Variables¶
# SQLite
export M9M_DB_TYPE=sqlite
export M9M_DB_PATH=./data/m9m.db
# PostgreSQL
export M9M_DB_TYPE=postgres
export M9M_POSTGRES_HOST=localhost
export M9M_POSTGRES_PORT=5432
export M9M_POSTGRES_DATABASE=m9m
export M9M_POSTGRES_USER=m9m
export M9M_POSTGRES_PASSWORD=secret
Schema Management¶
m9m automatically manages database schema:
- Creates tables on first run
- Runs migrations on upgrade
- No manual schema management needed
Backup¶
SQLite Backup¶
# Stop server first for consistent backup
cp ~/.m9m/data/m9m.db backup.db
# Or use SQLite backup
sqlite3 ~/.m9m/data/m9m.db ".backup backup.db"
PostgreSQL Backup¶
Data Stored¶
The database stores:
| Table | Contents |
|---|---|
workflows |
Workflow definitions |
executions |
Execution history and data |
credentials |
Encrypted credentials |
schedules |
Scheduled workflow configs |
settings |
Application settings |
Performance Tuning¶
PostgreSQL¶
Connection Pooling¶
For high-traffic deployments, use PgBouncer:
Troubleshooting¶
Connection Refused¶
Check PostgreSQL is running and accessible:
Permission Denied¶
Grant necessary permissions:
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO m9m;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO m9m;
Database Locked (SQLite)¶
Only one m9m instance can write to SQLite. Use PostgreSQL for multiple instances.