cube-js/cube · warning

The ${keyByDataSource('CUBEJS_DATABASE', dataSource)} is dep

Error message

The ${keyByDataSource('CUBEJS_DATABASE', dataSource)} is deprecated. Please, use the ${keyByDataSource('CUBEJS_DB_NAME', dataSource)} instead.

What it means

The legacy CUBEJS_DATABASE (and per-datasource suffixed variants) env var is deprecated in favor of CUBEJS_DB_NAME. Cube logs this warning when the deprecated var is read, but still returns its value for compatibility.

Source

Thrown at packages/cubejs-backend-shared/src/env.ts:631

      );
    }
    return val;
  },

  /**
   * Database name.
   * @deprecated
   */
  dbDatabase: ({
    required,
    dataSource,
    preAggregations,
  }: {
    dataSource: string,
    required?: boolean,
    preAggregations?: boolean,
  }) => {
    console.warn(
      `The ${
        keyByDataSource('CUBEJS_DATABASE', dataSource)
      } is deprecated. Please, use the ${
        keyByDataSource('CUBEJS_DB_NAME', dataSource)
      } instead.`
    );
    const val = get(keyByDataSource('CUBEJS_DATABASE', dataSource, preAggregations)).asString();
    if (required && !val) {
      throw new Error(
        `The ${
          keyByDataSource('CUBEJS_DATABASE', dataSource)
        } is required and missing.`
      );
    }
    return val;
  },

  /**

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Replace CUBEJS_DATABASE with CUBEJS_DB_NAME (suffixed variants become CUBEJS_DB_NAME_<DATA_SOURCE>)
  2. Remove the old variable after verifying the new one is picked up
  3. Restart the Cube process and confirm the warning is gone

Example fix

// before
CUBEJS_DATABASE=warehouse
// after
CUBEJS_DB_NAME=warehouse
Defensive patterns

Strategy: validation

Validate before calling

if (process.env.CUBEJS_DATABASE) console.warn('Use CUBEJS_DB_NAME instead of deprecated CUBEJS_DATABASE');

Prevention

When it happens

Trigger: env dbDatabase (or equivalent) is called for a datasource whose environment defines CUBEJS_DATABASE or CUBEJS_DATABASE_<DATA_SOURCE>.

Common situations: Very old deployment templates; migrations from legacy Cube versions; multi-tenant environments with suffixed vars like CUBEJS_DATABASE_DB1.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/1bcc2d069c4ba595. Report an issue: GitHub.