Documentation
Example: Add a Database
Provision a PostgreSQL, MySQL, MongoDB, or Redis service and connect it to your app in minutes.
1. Create the database
From your project, add a new Database service. Choose PostgreSQL, MySQL, MongoDB, or Redis, select a version, and optionally set CPU or memory limits that match your workload.
2. Connect your app
nouva injects connection strings into your app as environment variables. Use the private URL inside the platform for the best performance.
DATABASE_SESSION_URL=postgres://user:password@host:session-port/database?sslmode=require
MYSQL_URL=mysql://user:password@host:port/database
MONGODB_URI=mongodb://user:password@host:port/database?authSource=admin
3. PHP and Laravel: emulate prepared statements
PostgreSQL connections go through a transaction pooler. PDO before PHP 8.4 releases a prepared statement with a SQL DEALLOCATE the pooler cannot resolve, which aborts the transaction it happens in. Keep the provided URL, its TLS mode, and your bound parameters, and turn on prepare emulation for the connection.
config/database.php
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DATABASE_URL'),
'sslmode' => 'require',
'options' => [
// Managed PostgreSQL pools transactions. PDO before PHP 8.4 releases a
// prepared statement with a SQL DEALLOCATE the pooler cannot resolve.
PDO::ATTR_EMULATE_PREPARES => true,
],
],Confirm it with a parameterized write and a read back inside one transaction. Connecting and running SELECT 1 passes even when prepared statements are broken.
Verify the connection
$counter = DB::transaction(function () {
DB::insert(
'insert into counters (id, n) values (?, 1)
on conflict (id) do update set n = counters.n + 1',
['probe']
);
return DB::selectOne('select n from counters where id = ?', ['probe'])->n;
});PHP 8.4 or newer built against libpq 17 or newer needs no emulation. For advisory locks, LISTEN/NOTIFY, or other session-scoped work, add a second connection on DATABASE_SESSION_URL instead.
4. Verify and monitor
Deploy your app to load the new variables, then verify connectivity. Monitor logs and resource usage from the database service panel.