Database Schema

Complete reference for n8n-deploy database structure and relationships.

📋 Schema Overview

The database consists of 10 tables organized into 4 functional groups:

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

Current Schema Version: 8


🗂️ 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)
fileTEXT Custom filename (e.g., ‘my-workflow.json’)
file_folderTEXTNOT NULLDirectory containing workflow JSON file
server_idINTEGERFOREIGN KEYLinked n8n server reference
statusTEXTDEFAULT ‘active’Workflow status (active/inactive/archived)
created_atTIMESTAMPNOT NULLCreation timestamp
updated_atTIMESTAMP Last modification timestamp
last_syncedTIMESTAMP Last sync with n8n server
n8n_version_idINTEGER n8n version identifier
push_countINTEGERDEFAULT 0Number of times pushed to server
pull_countINTEGERDEFAULT 0Number of times pulled from server
scripts_pathTEXT Remote path for workflow scripts (v7)

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)
skip_ssl_verifyINTEGERDEFAULT 0Skip SSL verification (v8)
created_atTIMESTAMPNOT NULLCreation timestamp
last_usedTIMESTAMP Last connection timestamp

Indexes:

  • idx_servers_name on name (UNIQUE)
  • idx_servers_active on is_active

SSL Configuration: Use n8n-deploy server ssl <name> --skip-verify to enable SSL bypass for servers with self-signed certificates.

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: 8 (as of December 2025)

server_credentials Table

Stores server authentication credentials.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENTAuto-increment ID
server_idINTEGERFOREIGN KEYServer reference
credential_typeTEXTNOT NULLCredential type (ssh, api, etc.)
credential_dataTEXT Credential data (JSON)
created_atTIMESTAMP Creation timestamp

📁 Folder Synchronization Tables

n8n_folders Table

Stores n8n folder metadata for folder sync.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENTAuto-increment ID
folder_idTEXTNOT NULLn8n folder ID
nameTEXTNOT NULLFolder name
server_idINTEGERFOREIGN KEYServer reference
created_atTIMESTAMP Creation timestamp

folder_mappings Table

Maps local directories to remote n8n folders.

ColumnTypeConstraintsDescription
idINTEGERPRIMARY KEY AUTOINCREMENTAuto-increment ID
local_pathTEXTNOT NULLLocal directory path
folder_idINTEGERFOREIGN KEYn8n folder reference
server_idINTEGERFOREIGN KEYServer reference
created_atTIMESTAMP Creation timestamp

🔗 Relationship Diagram

erDiagram
    WORKFLOWS ||--o{ DEPENDENCIES : "has"
    WORKFLOWS }o--|| SERVERS : "linked to"
    SERVERS ||--o{ SERVER_API_KEYS : "uses"
    API_KEYS ||--o{ SERVER_API_KEYS : "linked to"
    SERVERS ||--o{ N8N_FOLDERS : "contains"
    SERVERS ||--o{ FOLDER_MAPPINGS : "maps"
    SERVERS ||--o{ SERVER_CREDENTIALS : "authenticates"
    N8N_FOLDERS ||--o{ FOLDER_MAPPINGS : "mapped by"

Key Relationships:

  • Workflows link to servers via server_id for automatic server resolution
  • Servers have SSL configuration (skip_ssl_verify) for self-signed certificates
  • Servers and API keys have many-to-many relationship via junction table
  • Folder mappings connect local paths to remote n8n folders

🔄 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