Thanks to visit codestin.com
Credit goes to docs.ever.works

Skip to main content

Database

The Ever Works Platform uses TypeORM for database access and supports multiple database engines.

Supported Databases

EngineUse CaseDriver
SQLiteDevelopment, single-user (default)better-sqlite3
PostgreSQLProduction recommendedpg
MySQL / MariaDBProduction alternativemysql2

SQLite is the default for development. It supports both in-memory mode (fastest, no persistence) and file-based storage.

Configuration

SQLite (Default)

DATABASE_TYPE=sqlite

# In-memory database (development default)
DATABASE_IN_MEMORY=true

# Or file-based storage
# DATABASE_PATH=/path/to/database.db

PostgreSQL

DATABASE_TYPE=postgres
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=your_password
DATABASE_NAME=ever_works

# Or use a connection URL
# DATABASE_URL=postgresql://user:pass@host:5432/dbname

MySQL

DATABASE_TYPE=mysql
DATABASE_HOST=localhost
DATABASE_PORT=3306
DATABASE_USERNAME=root
DATABASE_PASSWORD=your_password
DATABASE_NAME=ever_works

# Or use a connection URL
# DATABASE_URL=mysql://user:pass@host:3306/dbname

Common Options

VariableDefaultDescription
DATABASE_LOGGINGfalseEnable SQL query logging
DATABASE_SSL_MODEfalseEnable SSL/TLS for connections
DATABASE_CA_CERTCA certificate for SSL connections

Entities

The platform defines 16 TypeORM entities:

EntityTableDescription
WorkworksCore work with name, slug, description, generation status, deployment state, repository config, community PR settings
UserusersUser account with email, password, subscription info
WorkMemberwork_membersMany-to-many relationship between users and works with roles (owner, manager, editor, viewer)
WorkGenerationHistorywork_generation_historyTracks each generation run: method, status, metrics, item counts, duration
WorkSchedulework_schedulesScheduled update configuration: cadence, status, billing mode, failure tracking
WorkAdvancedPromptswork_advanced_promptsPer-work custom prompts for pipeline steps
OAuthTokenoauth_tokensOAuth provider tokens with access/refresh tokens and metadata
RefreshTokenrefresh_tokensJWT refresh tokens with family-based rotation, revocation tracking, and device info
NotificationnotificationsUser notifications with type, category, read/dismissed state, expiration
SubscriptionPlansubscription_plansPlan definitions: max works, allowed cadences, pricing
UserSubscriptionuser_subscriptionsActive subscriptions: plan, status, billing provider (Stripe/manual), period info
UsageLedgerEntryusage_ledger_entriesUsage tracking: trigger type, billing mode, units, amount, settlement status
CacheEntrycache_entriesKey-value cache entries with TTL expiration
PluginEntitypluginsPlugin registry: metadata, status, global settings
UserPluginEntityuser_pluginsPer-user plugin settings and API keys
WorkPluginEntitywork_pluginsPer-work plugin configuration and overrides

Auto-Sync

TypeORM's synchronize option is controlled by the DATABASE_AUTOMIGRATE environment variable (defaults to true). When enabled, it automatically creates and updates database tables to match entity definitions. Set DATABASE_AUTOMIGRATE=false in production and use migrations instead.

Docker Compose

The default compose.yaml uses SQLite with file-based storage:

services:
ever-works-api:
environment:
- DATABASE_TYPE=sqlite
- DATABASE_PATH=/app/apps/api/data/database.db
volumes:
- api_data:/app/apps/api/data

For PostgreSQL in Docker, add a PostgreSQL service and update the API environment:

services:
postgres:
image: postgres:16
environment:
POSTGRES_DB: ever_works
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
volumes:
- pg_data:/var/lib/postgresql/data

ever-works-api:
environment:
- DATABASE_TYPE=postgres
- DATABASE_HOST=postgres
- DATABASE_PORT=5432
- DATABASE_USERNAME=postgres
- DATABASE_PASSWORD=password
- DATABASE_NAME=ever_works