Skip to content

Commit f202cab

Browse files
committed
chore: add documentation for bundled feature flag
1 parent 2d27e1f commit f202cab

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

postgresql_embedded/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,30 @@ The following features are available:
110110
| `tokio` | Enables using tokio for async | No |
111111
| `zonky` | Enables zonky PostgreSQL binaries | No |
112112

113+
## Bundling PostgreSQL
114+
115+
To bundle PostgreSQL with your application, you can enable the `bundled` feature. This will download the PostgreSQL
116+
archive at compile time and include it in your binary. You should specify the version of PostgreSQL to bundle by
117+
setting the environment variable `POSTGRESQL_VERSION` to a specific version, e.g. `=17.2.0`. In order to use the bundled
118+
PostgreSQL, you will also need to set an explicit matching version at runtime in `Settings`:
119+
120+
```rust
121+
use postgresql_embedded::{Result, Settings, VersionReq};
122+
123+
#[tokio::main]
124+
async fn main() -> Result<()> {
125+
let settings = Settings {
126+
version: VersionReq::from_str("=17.2.0")?,
127+
..Default::default()
128+
};
129+
Ok(())
130+
}
131+
```
132+
133+
The PostgreSQL binaries can also be obtained from a different GitHub source by setting the `POSTGRESQL_RELEASES_URL`
134+
environment variable. The repository must contain the releases with archives in same structure as
135+
[theseus-rs/postgresql_binaries](https://github.com/theseus-rs/postgresql-binaries).
136+
113137
## Safety
114138

115139
This crate uses `#![forbid(unsafe_code)]` to ensure everything is implemented in 100% safe Rust.

0 commit comments

Comments
 (0)