{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://www.rubyschema.org/rails/database.json",
  "title": "Rails Database Configuration",
  "markdownDescription": "Configures database connections for Rails applications. Each top-level key represents an environment (development, test, production, etc.) that can contain either a single database configuration or multiple named database configurations for multi-database setups.\n\nSee the [Rails Guide](https://guides.rubyonrails.org/configuring.html#configuring-a-database) for more information.",
  "type": "object",
  "definitions": {
    "erb": {
      "type": "string",
      "pattern": "^<%=.*%>$"
    },
    "environment": {
      "title": "Database environment",
      "markdownDescription": "A database environment can contain either a single database configuration directly, or multiple named database configurations (e.g., `primary`, `replica`, `cache`) for multi-database setups.",
      "additionalProperties": { "$ref": "#/definitions/database" }
    },
    "database": {
      "title": "Database",
      "markdownDescription": "Database connection configuration. All adapter-specific options are passed through to the underlying database client library.\n\nSee the [Rails Guide](https://guides.rubyonrails.org/configuring.html#configuring-a-database) for more information.",
      "type": "object",
      "properties": {
        "adapter": {
          "markdownDescription": "The database adapter to use. Required unless `url` is set. Common values include:\n\n- `postgresql` - PostgreSQL\n- `mysql2` - MySQL/MariaDB\n- `sqlite3` - SQLite\n- `trilogy` - MySQL/MariaDB using the Trilogy client",
          "type": "string",
          "examples": ["postgresql", "mysql2", "sqlite3", "trilogy"]
        },
        "url": {
          "markdownDescription": "Complete database URL in the format `adapter://[username[:password]@]host[:port]/database[?param1=value1&...]`\n\nWhen specified, individual connection parameters (host, port, etc.) can be omitted. The URL can also be read from an environment variable.",
          "type": "string",
          "examples": [
            "postgresql://localhost/blog_development",
            "mysql2://root:password@127.0.0.1:3306/app_production?encoding=utf8mb4",
            "<%= ENV['DATABASE_URL'] %>"
          ]
        },
        "host": {
          "markdownDescription": "Database server hostname or IP address.\n\nFor PostgreSQL, defaults to a Unix-domain socket in /tmp. On machines without Unix-domain sockets, defaults to localhost.",
          "type": "string",
          "examples": ["localhost", "127.0.0.1", "db.example.com"]
        },
        "port": {
          "markdownDescription": "Database server port number.\n\nDefaults:\n- PostgreSQL: 5432\n- MySQL: 3306\n- SQLite: N/A (file-based)",
          "anyOf": [{ "type": "integer" }, { "$ref": "#/definitions/erb" }],
          "examples": [3306, 5432]
        },
        "database": {
          "markdownDescription": "The name of the database to connect to.\n\nFor SQLite, this is the path to the database file (e.g., `storage/development.sqlite3`).",
          "type": "string",
          "examples": [
            "myapp_development",
            "blog_production",
            "storage/development.sqlite3"
          ]
        },
        "username": {
          "markdownDescription": "Database username for authentication.",
          "type": ["string", "null"],
          "examples": ["deploy", "root", "postgres"]
        },
        "password": {
          "markdownDescription": "Database password for authentication.\n\nIt's recommended to use ERB to read this from an environment variable rather than committing it to version control.",
          "type": ["string", "null"],
          "examples": ["<%= ENV['DATABASE_PASSWORD'] %>"]
        },
        "max_connections": {
          "markdownDescription": "Maximum number of database connections in the connection pool.\n\nA connection pool synchronizes thread access to a limited number of database connections. This value should be at least the number of threads your server manages.\n\nFor Puma, this typically should match or exceed `max_threads`. Set to `nil` or `-1` for unlimited connections. Default is 5.",
          "anyOf": [
            { "type": "integer" },
            { "type": "null" },
            { "$ref": "#/definitions/erb" }
          ],
          "default": 5,
          "examples": [5, 25, "<%= ENV.fetch(\"RAILS_MAX_THREADS\") { 5 } %>"]
        },
        "min_connections": {
          "markdownDescription": "Minimum number of connections the pool will open and maintain. Default is 0.\n\nCannot be combined with `pool`; use `max_connections` instead.",
          "anyOf": [{ "type": "integer" }, { "$ref": "#/definitions/erb" }],
          "default": 0,
          "examples": [0, 2]
        },
        "pool": {
          "markdownDescription": "Maximum number of database connections in the connection pool. Default is 5.\n\nOn Rails 8.1+ prefer `max_connections`; `pool` is still read as a fallback. If both are set they must have the same value.",
          "anyOf": [{ "type": "integer" }, { "$ref": "#/definitions/erb" }],
          "default": 5,
          "examples": [5, 25]
        },
        "timeout": {
          "markdownDescription": "SQLite-specific: Timeout in milliseconds to wait for a database lock (busy timeout) before raising an error.\n\nWhen not set, SQLite does not wait. The Rails-generated `database.yml` sets this to `5000`.",
          "anyOf": [{ "type": "integer" }, { "$ref": "#/definitions/erb" }],
          "examples": [5000, 10000]
        },
        "checkout_timeout": {
          "markdownDescription": "Number of seconds to wait for a connection to become available in the pool before giving up and raising a timeout error. Default is 5.",
          "anyOf": [{ "type": "number" }, { "$ref": "#/definitions/erb" }],
          "default": 5,
          "examples": [5, 10]
        },
        "encoding": {
          "markdownDescription": "Character encoding to use for the database connection.\n\n- PostgreSQL: Sets `client_encoding` (e.g., `unicode`, `utf8`)\n- MySQL: Sets the connection character set with `SET NAMES` (e.g., `utf8mb4`)",
          "type": "string",
          "examples": ["unicode", "utf8", "utf8mb4"]
        },
        "socket": {
          "markdownDescription": "Path to a Unix domain socket for the database connection.\n\nUsed instead of `host` and `port` for local connections. Common for MySQL on many systems.",
          "type": "string",
          "examples": ["/tmp/mysql.sock", "/var/run/postgresql"]
        },
        "migrations_paths": {
          "markdownDescription": "Directory (or list of directories) containing migrations for this database, relative to the application root. Defaults to `db/migrate`.\n\nUseful for multi-database setups where each database has its own set of migrations (e.g., `db/cache_migrate`, `db/queue_migrate`).",
          "anyOf": [
            { "type": "string" },
            { "type": "array", "items": { "type": "string" } }
          ],
          "examples": [
            "db/cache_migrate",
            "db/queue_migrate",
            "db/cable_migrate"
          ]
        },
        "schema_search_path": {
          "markdownDescription": "PostgreSQL-specific: Comma-separated list of schemas to search when a table name is referenced without a schema qualifier.\n\nSets the `search_path` connection variable. `schema_order` is accepted as a legacy alias.",
          "type": "string",
          "examples": ["public,shared", "myapp,public"]
        },
        "prepared_statements": {
          "markdownDescription": "Enable or disable prepared statements for the connection.\n\nDefaults to `true` for PostgreSQL and SQLite, and `false` for `mysql2` and `trilogy`. The `trilogy` adapter does not support prepared statements and raises an error if this is `true`.",
          "anyOf": [{ "type": "boolean" }, { "$ref": "#/definitions/erb" }]
        },
        "advisory_locks": {
          "markdownDescription": "Enable or disable advisory locks (PostgreSQL and MySQL).\n\nAdvisory locks are used by Active Record to make database migrations concurrency safe. Default is `true`.\n\nSet to `false` when using PgBouncer in transaction pooling mode, as it doesn't support advisory locks.",
          "anyOf": [{ "type": "boolean" }, { "$ref": "#/definitions/erb" }],
          "default": true
        },
        "statement_limit": {
          "markdownDescription": "Maximum number of prepared statements to cache per connection.\n\nDefault is 1000. The more prepared statements in use, the more memory your database will require; lower this if your database is hitting memory limits.",
          "anyOf": [{ "type": "integer" }, { "$ref": "#/definitions/erb" }],
          "default": 1000,
          "examples": [200, 500, 1000]
        },
        "variables": {
          "markdownDescription": "Hash of session variables to set on connection establishment.\n\nFor PostgreSQL, these are set using `SET SESSION key TO value`. For MySQL, these are set using `SET @@SESSION.key = value`. Use the value `:default` to reset a variable to its global default.",
          "type": "object",
          "additionalProperties": {
            "anyOf": [
              { "type": "string" },
              { "type": "number" },
              { "type": "boolean" },
              { "$ref": "#/definitions/erb" }
            ]
          },
          "examples": [{ "statement_timeout": 5000 }, { "time_zone": "UTC" }]
        },
        "reaping_frequency": {
          "markdownDescription": "Frequency in seconds to periodically run the connection reaper.\n\nThe reaper removes dead and idle connections from the pool and performs pool maintenance. Defaults to 20 seconds, or the smallest of `idle_timeout`, `max_age` and `keepalive` if lower. Set to `nil` to disable.",
          "anyOf": [
            { "type": "number" },
            { "type": "null" },
            { "$ref": "#/definitions/erb" }
          ],
          "examples": [60, 300]
        },
        "connection_retries": {
          "markdownDescription": "Number of times to reconnect and retry safely retryable (idempotent) queries when the connection to the database fails.\n\nDefault is 1. Set to `0` to disable retries.",
          "anyOf": [{ "type": "integer" }, { "$ref": "#/definitions/erb" }],
          "default": 1,
          "examples": [1, 5, 10]
        },
        "retry_deadline": {
          "markdownDescription": "Maximum time in seconds after a query was first attempted during which it may be retried.\n\nIf this deadline has passed, an otherwise retryable query will not be retried even if `connection_retries` remain. Default is `nil` (no deadline).",
          "anyOf": [
            { "type": "number" },
            { "type": "null" },
            { "$ref": "#/definitions/erb" }
          ],
          "examples": [5, 30, 60]
        },
        "idle_timeout": {
          "markdownDescription": "Number of seconds that a connection will be kept unused in the pool before it is automatically disconnected.\n\nDefault is 300 seconds (5 minutes). Set to `0` to keep connections forever.",
          "anyOf": [
            { "type": "number" },
            { "type": "null" },
            { "$ref": "#/definitions/erb" }
          ],
          "default": 300,
          "examples": [300, 600]
        },
        "query_cache": {
          "markdownDescription": "Configure query caching for this database connection.\n\nBy default, identical queries within the same request or job return cached results. Set to an integer to change the maximum number of cached queries (default `100`), or to `false` to disable the query cache.",
          "anyOf": [
            { "type": "integer" },
            { "type": "boolean" },
            { "$ref": "#/definitions/erb" }
          ],
          "default": 100,
          "examples": [100, 200, false]
        },
        "replica": {
          "markdownDescription": "Indicates this configuration is for a read replica.\n\nSet to `true` for replica databases in a multi-database setup. Replicas are excluded from database tasks such as migrations.",
          "anyOf": [{ "type": "boolean" }, { "$ref": "#/definitions/erb" }],
          "examples": [true, false]
        },
        "sslmode": {
          "markdownDescription": "PostgreSQL-specific: SSL mode for the connection.",
          "type": "string",
          "enum": [
            "disable",
            "allow",
            "prefer",
            "require",
            "verify-ca",
            "verify-full"
          ],
          "markdownEnumDescriptions": [
            "No SSL connection attempted.",
            "Try non-SSL first, then SSL if that fails.",
            "Try SSL first, then non-SSL if that fails (default).",
            "Require SSL connection. Verify that the server certificate is issued by a trusted CA.",
            "Require SSL and verify that the server certificate is issued by a trusted certificate authority.",
            "Require SSL, verify the CA, and verify that the server certificate hostname matches the connection hostname."
          ]
        },
        "sslcert": {
          "markdownDescription": "PostgreSQL and MySQL: Path to the client SSL certificate file.",
          "type": "string",
          "examples": ["/path/to/client-cert.pem"]
        },
        "sslkey": {
          "markdownDescription": "PostgreSQL and MySQL: Path to the client SSL private key file.",
          "type": "string",
          "examples": ["/path/to/client-key.pem"]
        },
        "sslrootcert": {
          "markdownDescription": "PostgreSQL-specific: Path to the root SSL certificate authority (CA) file.",
          "type": "string",
          "examples": ["/path/to/ca-cert.pem"]
        },
        "insert_returning": {
          "markdownDescription": "PostgreSQL-specific: Control the use of `RETURNING` clause for `INSERT` statements.\n\nDefault is `true`. When enabled, Rails retrieves the inserted record's values in a single query.",
          "anyOf": [{ "type": "boolean" }, { "$ref": "#/definitions/erb" }],
          "default": true
        },
        "min_messages": {
          "markdownDescription": "PostgreSQL-specific: Minimum message severity level to display. Sets the `client_min_messages` session parameter.\n\nDefault is `warning`.",
          "type": "string",
          "default": "warning",
          "enum": [
            "debug5",
            "debug4",
            "debug3",
            "debug2",
            "debug1",
            "log",
            "notice",
            "warning",
            "error"
          ],
          "markdownEnumDescriptions": [
            "Most verbose debugging output.",
            "Verbose debugging output.",
            "Detailed debugging output.",
            "Moderate debugging output.",
            "Basic debugging output.",
            "Log messages for database administrators.",
            "Helpful notices and informational messages.",
            "Warning messages about potential problems.",
            "Only error messages (suppresses all lower severity)."
          ]
        },
        "connect_timeout": {
          "markdownDescription": "Maximum time in seconds to wait while establishing a connection to the database server.\n\nDefault varies by adapter. For PostgreSQL, default is system-dependent (often no timeout).",
          "anyOf": [{ "type": "integer" }, { "$ref": "#/definitions/erb" }],
          "examples": [5, 10, 30]
        },
        "read_timeout": {
          "markdownDescription": "MySQL-specific: Maximum time in seconds to wait for data from the server after a query is sent.",
          "anyOf": [{ "type": "integer" }, { "$ref": "#/definitions/erb" }],
          "examples": [5, 10, 30]
        },
        "write_timeout": {
          "markdownDescription": "MySQL-specific: Maximum time in seconds to wait when writing data to the server.",
          "anyOf": [{ "type": "integer" }, { "$ref": "#/definitions/erb" }],
          "examples": [5, 10, 30]
        },
        "reconnect": {
          "markdownDescription": "MySQL-specific: Whether to automatically reconnect if the connection is lost.\n\nDefault is `false`. Not recommended as it can mask connection issues.",
          "anyOf": [{ "type": "boolean" }, { "$ref": "#/definitions/erb" }],
          "default": false
        },
        "strict": {
          "markdownDescription": "Enable strict mode.\n\n- MySQL: Enables `STRICT_ALL_TABLES` SQL mode so MySQL rejects invalid data and raises errors instead of warnings. Default is `true`.\n- SQLite: Disallows double-quoted string literals in SQL statements. Defaults to `config.active_record.sqlite3_adapter_strict_strings_by_default` (`false`).",
          "anyOf": [{ "type": "boolean" }, { "$ref": "#/definitions/erb" }]
        },
        "flags": {
          "markdownDescription": "Client flags to set when opening the connection.\n\n- `mysql2`: An integer bitmask or an array of flag names (e.g. `[\"-MULTI_STATEMENTS\"]`). `FOUND_ROWS` is always added.\n- SQLite: An integer bitmask of `SQLite3::Constants::Open` flags.\n\nRarely needed in typical applications.",
          "anyOf": [
            { "type": "integer" },
            { "type": "array", "items": { "type": "string" } },
            { "$ref": "#/definitions/erb" }
          ]
        },
        "collation": {
          "markdownDescription": "MySQL-specific: Collation to use for the connection, applied together with `encoding` via `SET NAMES ... COLLATE ...`.",
          "type": "string",
          "examples": ["utf8mb4_unicode_ci", "utf8mb4_0900_ai_ci"]
        },
        "wait_timeout": {
          "markdownDescription": "MySQL-specific: Number of seconds the server waits for activity on the connection before closing it. Sets the `wait_timeout` session variable.\n\nDefault is `2147483`.",
          "anyOf": [{ "type": "integer" }, { "$ref": "#/definitions/erb" }],
          "default": 2147483
        },
        "sslca": {
          "markdownDescription": "MySQL-specific: Path to the SSL certificate authority (CA) file.",
          "type": "string",
          "examples": ["/path/to/ca-cert.pem"]
        },
        "sslcapath": {
          "markdownDescription": "MySQL-specific: Path to a directory containing trusted SSL CA certificates.",
          "type": "string"
        },
        "sslcipher": {
          "markdownDescription": "MySQL-specific: List of permitted ciphers for SSL encryption.",
          "type": "string"
        },
        "ssl_mode": {
          "markdownDescription": "MySQL-specific: SSL mode for the connection. For `trilogy`, values are mapped to `Trilogy::SSL_*` constants (e.g. `required` becomes `SSL_MODE_REQUIRED`).",
          "anyOf": [
            {
              "enum": [
                "disabled",
                "preferred",
                "required",
                "verify_ca",
                "verify_identity"
              ]
            },
            { "type": "string" },
            { "type": "integer" }
          ]
        },
        "pragmas": {
          "markdownDescription": "SQLite-specific: Hash of [PRAGMA](https://www.sqlite.org/pragma.html) statements to set on each connection. Merged with the Rails defaults:\n\n- `foreign_keys: true`\n- `journal_mode: wal`\n- `synchronous: normal`\n- `mmap_size: 134217728` (128 MB)\n- `journal_size_limit: 67108864` (64 MB)\n- `cache_size: 2000`",
          "type": "object",
          "additionalProperties": {
            "anyOf": [
              { "type": "string" },
              { "type": "number" },
              { "type": "boolean" },
              { "$ref": "#/definitions/erb" }
            ]
          },
          "examples": [{ "journal_mode": "wal", "synchronous": "normal" }]
        },
        "extensions": {
          "markdownDescription": "SQLite-specific: List of [SQLite extensions](https://sqlite.org/loadext.html) to load (requires `sqlite3` gem v2.4.0 or later). Each entry may be a filesystem path or the name of a class that responds to `.to_path`.",
          "type": "array",
          "items": { "type": "string" },
          "examples": [["SQLean::UUID", ".sqlpkg/nalgeon/crypto/crypto.so"]]
        },
        "keepalive": {
          "markdownDescription": "Number of seconds between keepalive checks on idle connections in the pool.\n\nDefault is 600 seconds. Set to `false` to disable.",
          "anyOf": [
            { "type": "number" },
            { "type": "boolean" },
            { "$ref": "#/definitions/erb" }
          ],
          "default": 600,
          "examples": [300, 600, false]
        },
        "max_age": {
          "markdownDescription": "Number of seconds the pool will allow a connection to exist before retiring it at its next checkin.\n\nDefault is unlimited.",
          "anyOf": [{ "type": "number" }, { "$ref": "#/definitions/erb" }],
          "examples": [3600, 86400]
        },
        "pool_jitter": {
          "markdownDescription": "Maximum reduction factor to apply to the `max_age` and `keepalive` intervals, so that connections don't all expire at once.\n\nDefault is `0.2`. Range `0.0`-`1.0`.",
          "anyOf": [
            { "type": "number", "minimum": 0, "maximum": 1 },
            { "$ref": "#/definitions/erb" }
          ],
          "default": 0.2
        },
        "min_threads": {
          "markdownDescription": "Minimum number of threads in this pool's asynchronous query executor. Only used when `config.active_record.async_query_executor` is `:multi_thread_pool`.\n\nDefault is 0.",
          "anyOf": [{ "type": "integer" }, { "$ref": "#/definitions/erb" }],
          "default": 0
        },
        "max_threads": {
          "markdownDescription": "Maximum number of threads in this pool's asynchronous query executor. Only used when `config.active_record.async_query_executor` is `:multi_thread_pool`.\n\nDefaults to `max_connections`, capped at 5.",
          "anyOf": [{ "type": "integer" }, { "$ref": "#/definitions/erb" }]
        },
        "verify_timeout": {
          "markdownDescription": "Number of seconds since the connection's last activity during which it is assumed to still be alive and is not re-verified before use.\n\nDefault is 2.",
          "anyOf": [{ "type": "integer" }, { "$ref": "#/definitions/erb" }],
          "default": 2
        },
        "default_timezone": {
          "markdownDescription": "Time zone used for this connection when reading and writing dates and times. Overrides `config.active_record.default_timezone` for this database.",
          "enum": ["utc", "local"]
        },
        "database_tasks": {
          "markdownDescription": "Whether database tasks (`db:create`, `db:migrate`, etc.) should run against this database. Set to `false` for databases that are managed externally.\n\nDefault is `true` (always `false` for replicas).",
          "anyOf": [{ "type": "boolean" }, { "$ref": "#/definitions/erb" }],
          "default": true
        },
        "schema_dump": {
          "markdownDescription": "Filename of the schema dump for this database, relative to `db/`. Set to `false` to disable dumping the schema.\n\nDefaults to `schema.rb` / `structure.sql` for the primary database, and `<name>_schema.rb` / `<name>_structure.sql` for others.",
          "anyOf": [
            { "type": "string" },
            { "type": "boolean", "const": false },
            { "type": "null" }
          ],
          "examples": ["cache_schema.rb", false]
        },
        "schema_format": {
          "markdownDescription": "Format used to dump and load the schema for this database. Overrides `config.active_record.schema_format`.",
          "enum": ["ruby", "sql"],
          "markdownEnumDescriptions": [
            "Dump the schema as Ruby (`schema.rb`).",
            "Dump the schema as SQL (`structure.sql`)."
          ]
        },
        "schema_cache_path": {
          "markdownDescription": "Path to the schema cache dump file for this database.\n\nDefaults to `db/schema_cache.yml` for the primary database and `db/<name>_schema_cache.yml` for others.",
          "type": "string",
          "examples": ["db/schema_cache.yml"]
        },
        "seeds": {
          "markdownDescription": "Whether `db:prepare` should load `db/seeds.rb` when creating this database.\n\nDefaults to `true` for the primary database and `false` for others.",
          "anyOf": [{ "type": "boolean" }, { "$ref": "#/definitions/erb" }]
        },
        "use_metadata_table": {
          "markdownDescription": "Whether to store environment and schema information in the internal `ar_internal_metadata` table. Set to `false` when working with a shared database or a database user that cannot create tables.\n\nDefault is `true`.",
          "anyOf": [{ "type": "boolean" }, { "$ref": "#/definitions/erb" }],
          "default": true
        }
      },
      "anyOf": [
        { "required": ["adapter"] },
        { "required": ["url"] },
        { "required": ["host"] },
        { "required": ["port"] },
        { "required": ["database"] },
        { "required": ["username"] },
        { "required": ["password"] },
        { "required": ["max_connections"] },
        { "required": ["min_connections"] },
        { "required": ["pool"] },
        { "required": ["timeout"] },
        { "required": ["checkout_timeout"] },
        { "required": ["encoding"] },
        { "required": ["socket"] },
        { "required": ["migrations_paths"] },
        { "required": ["schema_search_path"] },
        { "required": ["prepared_statements"] },
        { "required": ["advisory_locks"] },
        { "required": ["statement_limit"] },
        { "required": ["variables"] },
        { "required": ["reaping_frequency"] },
        { "required": ["connection_retries"] },
        { "required": ["retry_deadline"] },
        { "required": ["idle_timeout"] },
        { "required": ["query_cache"] },
        { "required": ["replica"] },
        { "required": ["sslmode"] },
        { "required": ["sslcert"] },
        { "required": ["sslkey"] },
        { "required": ["sslrootcert"] },
        { "required": ["insert_returning"] },
        { "required": ["min_messages"] },
        { "required": ["connect_timeout"] },
        { "required": ["read_timeout"] },
        { "required": ["write_timeout"] },
        { "required": ["reconnect"] },
        { "required": ["strict"] },
        { "required": ["flags"] },
        { "required": ["collation"] },
        { "required": ["wait_timeout"] },
        { "required": ["sslca"] },
        { "required": ["sslcapath"] },
        { "required": ["sslcipher"] },
        { "required": ["ssl_mode"] },
        { "required": ["pragmas"] },
        { "required": ["extensions"] },
        { "required": ["keepalive"] },
        { "required": ["max_age"] },
        { "required": ["pool_jitter"] },
        { "required": ["min_threads"] },
        { "required": ["max_threads"] },
        { "required": ["verify_timeout"] },
        { "required": ["default_timezone"] },
        { "required": ["database_tasks"] },
        { "required": ["schema_dump"] },
        { "required": ["schema_format"] },
        { "required": ["schema_cache_path"] },
        { "required": ["seeds"] },
        { "required": ["use_metadata_table"] }
      ]
    }
  },
  "properties": {
    "default": {
      "markdownDescription": "Shared configuration that can be inherited by other environments using YAML anchors and aliases (e.g., `<<: *default`).\n\nCan contain either a single database configuration or multiple named configurations.",
      "oneOf": [
        { "$ref": "#/definitions/environment" },
        { "$ref": "#/definitions/database" }
      ]
    },
    "production": {
      "markdownDescription": "Configuration for the production environment.\n\nCan contain either a single database configuration or multiple named configurations (e.g., `primary`, `replica`).",
      "oneOf": [
        { "$ref": "#/definitions/environment" },
        { "$ref": "#/definitions/database" }
      ]
    },
    "development": {
      "markdownDescription": "Configuration for the development environment.\n\nCan contain either a single database configuration or multiple named configurations.",
      "oneOf": [
        { "$ref": "#/definitions/environment" },
        { "$ref": "#/definitions/database" }
      ]
    },
    "test": {
      "markdownDescription": "Configuration for the test environment.\n\nCan contain either a single database configuration or multiple named configurations.",
      "oneOf": [
        { "$ref": "#/definitions/environment" },
        { "$ref": "#/definitions/database" }
      ]
    }
  },
  "additionalProperties": {
    "markdownDescription": "Custom environment configuration (e.g., `staging`, `qa`).\n\nCan contain either a single database configuration or multiple named configurations.",
    "oneOf": [
      { "$ref": "#/definitions/environment" },
      { "$ref": "#/definitions/database" }
    ]
  }
}
