MySQL Schema

This section provides the MySQL queries required to create the database tables needed by the system. Run these queries on the MySQL database used by the Configuration Dashboard and the Gateway before starting the system for the first time.

📘

The MySQL database is provided and managed by you.

Create Tables

CREATE TABLE IF NOT EXISTS secret_key (
    id VARCHAR(36) PRIMARY KEY,
    key_value VARCHAR(255) NOT NULL,
    key_version BIGINT NOT NULL,
    secret_type VARCHAR(255) NOT NULL UNIQUE,
    created DATETIME(3) NOT NULL,
    updated DATETIME(3) NOT NULL
);

CREATE TABLE IF NOT EXISTS revoked_jwt(
    id VARCHAR(36) PRIMARY KEY, 
    expires_at DATETIME(3) NOT NULL,
    token_id VARCHAR(36) NOT NULL UNIQUE,
    token_type VARCHAR(255) NOT NULL,
    
    INDEX idx_expires(expires_at)
);

CREATE TABLE IF NOT EXISTS tenant (
    id VARCHAR(36) PRIMARY KEY,
    tenant_id VARCHAR(36) NOT NULL UNIQUE,
    name VARCHAR(255) NOT NULL,
    app_id VARCHAR(36) NOT NULL UNIQUE,
    app_key VARCHAR(255) NOT NULL,
    encrypt_key VARCHAR(255) NOT NULL,
    hash_key VARCHAR(255) NOT NULL,
    saved_config JSON NOT NULL,
    active_config JSON,
    created DATETIME(3) NOT NULL,     
    updated DATETIME(3) NOT NULL
);

CREATE TABLE IF NOT EXISTS route (
    id VARCHAR(36) PRIMARY KEY,
    route_id VARCHAR(36) NOT NULL UNIQUE,
    name VARCHAR(255) NOT NULL,
    app_route_id VARCHAR(36) NOT NULL UNIQUE,
    tenant_ref VARCHAR(36) NOT NULL,
    saved_config JSON NOT NULL,
    active_config JSON,
    created DATETIME(3) NOT NULL,     
    updated DATETIME(3) NOT NULL,
    FOREIGN KEY (tenant_ref) REFERENCES tenant(id) ON DELETE CASCADE,
    
    INDEX idx_tenant_route(tenant_ref, route_id),
    INDEX idx_tenant_appRoute(tenant_ref, app_route_id)
);

CREATE TABLE IF NOT EXISTS tenant_user (
    id VARCHAR(36) PRIMARY KEY,
    tenant_user_id VARCHAR(36) NOT NULL UNIQUE,
    tenant_ref VARCHAR(36) NOT NULL,
    username VARCHAR(255) NOT NULL UNIQUE,  
    username_hash VARCHAR(255) NOT NULL UNIQUE,
    username_type VARCHAR(255) NOT NULL,
    authorities JSON NOT NULL,                            
    user_password VARCHAR(255) NOT NULL,
    source VARCHAR(255) NOT NULL,
    user_data MEDIUMBLOB,
    confirmed BOOL NOT NULL,
    confirm_details JSON,
    password_reset_details JSON,
    created DATETIME(3) NOT NULL,
    updated DATETIME(3) NOT NULL,
    FOREIGN KEY (tenant_ref) REFERENCES tenant(id) ON DELETE CASCADE,
    
    INDEX idx_tenant_source_tenantUser(tenant_ref, source, tenant_user_id)
);

Read Tables

📘

The SELECT queries below are intended only for development environments to inspect data quickly. Such queries should be avoided in production to prevent performance issues from fetching all rows.

SELECT id, key_value, key_version, secret_type, updated, created 
FROM secret_key;

SELECT id, expires_at, token_id, token_type 
FROM revoked_jwt;

SELECT id, tenant_id, name, app_id, app_key, encrypt_key, hash_key, saved_config, active_config, created, updated 
FROM tenant;
	
SELECT id, route_id, name, app_route_id, tenant_ref, saved_config, active_config, created, updated 
FROM route;

SELECT id, tenant_user_id, tenant_ref, username, username_hash, username_type, authorities, user_password, source, user_data, confirmed, confirm_details, password_reset_details, created, updated 
FROM tenant_user;

Did this page help you?