{"record":{"id":"46d92732945e27d2","repo":"flarum/framework","slug":"please-specify-the-schema-name","errorCode":null,"errorMessage":"Please specify the schema name.","messagePattern":"Please specify the schema name\\.","errorType":"validation","errorClass":"ValidationFailed","httpStatus":null,"severity":"error","filePath":"framework/core/src/Install/DatabaseConfig.php","lineNumber":64,"sourceCode":"\n        if (! in_array($this->driver, ['mysql', 'mariadb', 'sqlite', 'pgsql'])) {\n            throw new ValidationFailed('Currently, only MySQL, MariaDB, SQLite and PostgreSQL are supported.');\n        }\n\n        if (empty($this->host) && in_array($this->driver, ['mysql', 'mariadb', 'pgsql'])) {\n            throw new ValidationFailed('Please specify the hostname of your database server.');\n        }\n\n        if (($this->port < 1 || $this->port > 65535) && in_array($this->driver, ['mysql', 'mariadb', 'pgsql'])) {\n            throw new ValidationFailed('Please provide a valid port number between 1 and 65535.');\n        }\n\n        if (empty($this->database)) {\n            throw new ValidationFailed('Please specify the database name.');\n        }\n\n        if (empty($this->schema) && $this->driver == 'pgsql') {\n            throw new ValidationFailed('Please specify the schema name.');\n        }\n\n        if (empty($this->username) && in_array($this->driver, ['mysql', 'mariadb', 'pgsql'])) {\n            throw new ValidationFailed('Please specify the username for accessing the database.');\n        }\n\n        if (! empty($this->prefix)) {\n            if (! preg_match('/^[\\pL\\pM\\pN_]+$/u', $this->prefix)) {\n                throw new ValidationFailed('The prefix may only contain characters and underscores.');\n            }\n\n            $maxPrefix = DatabaseRequirements::maxTablePrefixLength($this->driver);\n\n            if ($maxPrefix !== null && strlen($this->prefix) > $maxPrefix) {\n                throw new ValidationFailed(\"The prefix should be no longer than $maxPrefix characters on $this->driver.\");\n            }\n        }\n    }","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/flarum/framework/blob/4b939f685389bfe8a380e9e28ddf305a1c66950c/framework/core/src/Install/DatabaseConfig.php#L46-L82","documentation":"ValidationFailed thrown by DatabaseConfig::validate when the schema is empty and the driver is PostgreSQL. PostgreSQL organizes tables into schemas (default 'public'), and the installer requires one explicitly. Other drivers do not have this requirement.","triggerScenarios":"Constructing DatabaseConfig with driver 'pgsql' and an empty schema property.","commonSituations":"MySQL-to-PostgreSQL migration where the schema field was never filled; .env missing DB_SCHEMA equivalent; users unaware PostgreSQL needs a schema; private-schema setups where the default 'public' was removed.","solutions":["Set the schema property to 'public' (the default PostgreSQL schema) or your custom schema.","Ensure the target schema exists in the PostgreSQL database and the user has rights on it.","If the driver is not pgsql, ignore — this check only applies to PostgreSQL."],"exampleFix":"// before\nnew DatabaseConfig(driver: 'pgsql', host: 'db', port: 5432, database: 'app', schema: '');\n// after\nnew DatabaseConfig(driver: 'pgsql', host: 'db', port: 5432, database: 'app', schema: 'public');","handlingStrategy":"validation","validationCode":"if ($driver === 'pgsql' && trim((string) $schema) === '') {\n    $schema = 'public';\n}\n$config = new DatabaseConfig(driver: $driver, host: $host, port: $port, database: $database, schema: $schema);","typeGuard":"function hasSchema(array $cfg): bool {\n    return $cfg['driver'] !== 'pgsql' || (isset($cfg['schema']) && trim((string) $cfg['schema']) !== '');\n}","tryCatchPattern":"try {\n    $config = new DatabaseConfig(...$input);\n} catch (ValidationFailed $e) {\n    if (str_contains($e->getMessage(), 'schema')) {\n        $errors['schema'] = \"PostgreSQL requires a schema (use 'public').\";\n    }\n}","preventionTips":["Default schema to 'public' for pgsql in the installer.","Only show the schema field for PostgreSQL to avoid confusion.","Verify the schema exists via \"SELECT 1 FROM pg_namespace WHERE nspname = ?\" before install."],"tags":["database","postgresql","schema","config"],"backgroundTag":"missing-required-config-field","analyzedSha":"4b939f685389bfe8a380e9e28ddf305a1c66950c","analyzedAt":"2026-09-15T18:09:20.879Z","contentChangedAt":"2026-09-15T18:09:20.879Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}