{"record":{"id":"02fb2bccacad6a01","repo":"cube-js/cube","slug":"the-keybydatasource-cubejs-db-schema-datasour","errorCode":null,"errorMessage":"The ${keyByDataSource('CUBEJS_DB_SCHEMA', dataSource)} is required and missing.","messagePattern":"The (.+?) is required and missing\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-backend-shared/src/env.ts","lineNumber":609,"sourceCode":"  dbSchema: ({\n    required,\n    dataSource,\n    preAggregations,\n  }: {\n    dataSource: string,\n    required?: boolean,\n    preAggregations?: boolean,\n  }) => {\n    console.warn(\n      `The ${\n        keyByDataSource('CUBEJS_DB_SCHEMA', dataSource)\n      } is deprecated. Please, use the ${\n        keyByDataSource('CUBEJS_DB_NAME', dataSource)\n      } instead.`\n    );\n    const val = get(keyByDataSource('CUBEJS_DB_SCHEMA', dataSource, preAggregations)).asString();\n    if (required && !val) {\n      throw new Error(\n        `The ${\n          keyByDataSource('CUBEJS_DB_SCHEMA', dataSource)\n        } is required and missing.`\n      );\n    }\n    return val;\n  },\n\n  /**\n   * Database name.\n   * @deprecated\n   */\n  dbDatabase: ({\n    required,\n    dataSource,\n    preAggregations,\n  }: {\n    dataSource: string,","sourceCodeStart":591,"sourceCodeEnd":627,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-backend-shared/src/env.ts#L591-L627","documentation":"cubejsDbSchema reads CUBEJS_DB_SCHEMA (per data source) and, when required: true is passed and the variable is unset/empty, throws an error naming the resolved variable. CUBEJS_DB_SCHEMA is deprecated in favor of CUBEJS_DB_NAME, so hitting this usually signals legacy configuration.","triggerScenarios":"Calling the schema accessor with required: true while neither CUBEJS_DB_SCHEMA nor CUBEJS_DS_<DATASOURCE>_DB_SCHEMA is set; often after Cube logs the deprecation warning pointing to CUBEJS_DB_NAME.","commonSituations":"Older Cube configs still using CUBEJS_DB_SCHEMA after upgrade; teams renaming vars but leaving required checks; per-data-source setups missing the DS-prefixed schema var.","solutions":["Migrate to CUBEJS_DB_NAME (or CUBEJS_DS_<DATASOURCE>_DB_NAME), as the schema variable is deprecated.","If you must keep it, set CUBEJS_DB_SCHEMA (or CUBEJS_DS_<DATASOURCE>_DB_SCHEMA) to the schema/database name.","Search your deployment manifests for CUBEJS_DB_SCHEMA and reconcile naming with the dataSource passed in code.","Remove required: true if the schema is optional for your driver."],"exampleFix":"// before\nCUBEJS_DB_SCHEMA=public   # deprecated, may still throw if missing per DS\n// after\nCUBEJS_DB_NAME=analytics","handlingStrategy":"try-catch","validationCode":"if (process.env.CUBEJS_DB_SCHEMA !== undefined) {\n  console.warn('CUBEJS_DB_SCHEMA is deprecated; use CUBEJS_DB_NAME instead');\n}\nconst dsKey = `CUBEJS_DS_${dataSource.toUpperCase()}_DB_SCHEMA`;\nif (!process.env[dsKey] && !process.env.CUBEJS_DB_SCHEMA && !process.env.CUBEJS_DB_NAME)\n  throw new Error(`Set CUBEJS_DB_NAME for data source ${dataSource}`);","typeGuard":null,"tryCatchPattern":"try {\n  const schema = getEnv('dbSchema', { dataSource, required: true });\n} catch (e) {\n  if (String(e.message).includes('DB_SCHEMA') && e.message.includes('required and missing')) {\n    console.error('Migrate to CUBEJS_DB_NAME; CUBEJS_DB_SCHEMA is deprecated');\n  }\n  throw e;\n}","preventionTips":["Migrate off CUBEJS_DB_SCHEMA to CUBEJS_DB_NAME during upgrades.","Grep deployment manifests for deprecated var names before releases.","Drop required: true when the schema is optional."],"tags":["configuration","environment-variables","deprecated","missing-var"],"backgroundTag":"missing-env-var","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}