Database Schema

Complete reference for n8n-deploy database structure and relationships.

📋 Schema Overview

The database consists of 7 tables organized into 3 functional groups:

  1. Workflow Management (2 tables)
  2. Server & API Key Management (3 tables)
  3. Configuration & Schema (2 tables)

Current Schema Version: 2.0


🗂️ Workflow Management Tables

workflows Table

Stores workflow metadata and file references.

ColumnTypeConstraintsDescription
idTEXTPRIMARY KEYn8n workflow ID (unique identifier)
nameTEXTNOT NULLWorkflow display name (UTF-8 supported)
file_pathTEXTNOT NULLRelative path to workflow JSON file
statusTEXTDEFAULT ‘active’Workflow status (active/inactive/archived)
tagsTEXT Comma-separated tags
created_atTIMESTAMPNOT NULLCreation timestamp
updated_atTIMESTAMP Last modification timestamp
last_syncedTIMESTAMP Last sync with n8n server
n8n_version_idINTEGERFOREIGN KEYn8n version reference

Indexes:

  • idx_workflows_name on name (for search operations)
  • idx_workflows_status on status (for filtering)

dependencies Table

Records workflow dependency relationships for graph-push functionality.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENTAuto-increment ID
workflow_idTEXTFOREIGN KEYWorkflow that has dependency
depends_onTEXTNOT NULLWorkflow that is depended upon
dependency_typeTEXTDEFAULT ‘wf’Dependency type (workflow)
created_atTIMESTAMPDEFAULT CURRENT_TIMESTAMPRecord creation time

Foreign Keys:

  • workflow_idworkflows.id (CASCADE DELETE)

Usage: If “Workflow A” depends on “Workflow B”, the row stores workflow_id='A' and depends_on='B'. This ensures B is deployed before A in graph-push operations.


🖥️ Server & API Key Management Tables

servers Table

Stores n8n server configurations.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENTAuto-increment ID
urlTEXTNOT NULLServer URL (e.g., http://n8n.example.com:5678)
nameTEXTNOT NULL UNIQUEServer name (UTF-8, emojis supported)
is_activeINTEGERDEFAULT 1Active status (1=active, 0=inactive)
created_atTIMESTAMPNOT NULLCreation timestamp
last_usedTIMESTAMP Last connection timestamp

Indexes:

  • idx_servers_name on name (UNIQUE)
  • idx_servers_active on is_active

api_keys Table

Stores n8n API keys (plain text JWT tokens).

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENTAuto-increment ID
nameTEXTNOT NULL UNIQUEKey identifier (UTF-8 supported)
api_keyTEXTNOT NULLPlain text n8n JWT token
descriptionTEXT Optional key documentation
created_atTIMESTAMPNOT NULLCreation timestamp
last_used_atTIMESTAMP Last usage timestamp
is_activeINTEGERDEFAULT 1Active status (1=active, 0=inactive)

Indexes:

  • idx_api_keys_name on name (UNIQUE)

Security: API keys stored in plain text. Protect database file with chmod 600 permissions.

server_api_keys Table

Junction table for many-to-many relationship between servers and API keys.

ColumnTypeConstraintsDescription
server_idINTEGERFOREIGN KEYServer reference
api_key_idINTEGERFOREIGN KEYAPI key reference
created_atTIMESTAMPNOT NULLLink creation timestamp

Primary Key: Composite (server_id, api_key_id)

Foreign Keys:

  • server_idservers.id (CASCADE DELETE)
  • api_key_idapi_keys.id (CASCADE DELETE)

Cascade Behavior:

  • Deleting a server removes all its links (preserves API keys)
  • Deleting an API key removes all its links (preserves servers)

⚙️ Configuration & Schema Tables

configurations Table

Stores application configuration and backup metadata.

ColumnTypeConstraintsDescription
keyTEXTPRIMARY KEYConfiguration key
valueTEXT Configuration value (backup metadata, SHA256)
updated_atTIMESTAMP Last update timestamp

Common keys:

  • last_backup_path - Path to most recent backup
  • last_backup_checksum - SHA256 hash of last backup
  • last_backup_timestamp - Backup creation time

schema_info Table

Tracks database schema version for migrations.

ColumnTypeConstraintsDescription
versionINTEGERPRIMARY KEYSchema version number
migration_scriptTEXT SQL migration script
applied_atTIMESTAMP Migration application timestamp

Current Version: 2 (as of October 2025)


🔗 Relationship Diagram

workflows 1──────┤ many dependencies
                 │
servers many─────┤├─── many api_keys
                 ││     (via server_api_keys)
                 ││
                 └┴──── configurations
                        schema_info

🔄 Schema Migrations

Schema changes are tracked via the schema_info table. Each migration increments the version number.

Migration process:

  1. Check current schema version
  2. Apply incremental migrations if needed
  3. Record migration in schema_info
  4. Verify integrity

Example migration check:

# Check current schema version
sqlite3 n8n-deploy.db "SELECT version FROM schema_info ORDER BY version DESC LIMIT 1;"


💡 Schema Design Principles

  1. Simplicity: Minimal normalization for performance
  2. UTF-8 Support: International characters in names
  3. Plain Text Keys: No encryption complexity
  4. Cascade Deletes: Automatic cleanup of relationships
  5. Timestamps: Track creation and usage
  6. Versioning: Schema evolution via migrations
  7. Integrity: Foreign key constraints enforced