2023-11-26 22:44:53 +00:00
|
|
|
# Postgres Flake Template
|
|
|
|
|
|
|
|
This is a template for constructing a working environment for local
|
|
|
|
[Postgres](https://www.postgresql.org/) (version 15.5) usage. [direnv](https://direnv.net/)
|
|
|
|
can be used to a launch a dev shell upon entering this directory (refer to
|
|
|
|
`.envrc`). Otherwise run via:
|
|
|
|
```bash
|
|
|
|
$> nix develop
|
|
|
|
```
|
|
|
|
|
|
|
|
## Quickstart
|
|
|
|
|
2023-11-28 17:21:56 +00:00
|
|
|
An empty Postgres cluster is initialized at `/data`. To start the database, run
|
|
|
|
the following:
|
2023-11-26 22:44:53 +00:00
|
|
|
```bash
|
2023-11-28 17:56:18 +00:00
|
|
|
$> pg_ctl start -o --unix_socket_directories="$PWD/data"
|
2023-11-26 22:44:53 +00:00
|
|
|
```
|
|
|
|
To shut the database down, run:
|
|
|
|
```bash
|
2023-11-28 16:18:43 +00:00
|
|
|
$> pg_ctl stop
|
2023-11-26 22:44:53 +00:00
|
|
|
```
|
2023-11-28 17:21:56 +00:00
|
|
|
You can connect to this database from the project root directory by running:
|
|
|
|
```bash
|
2023-11-28 17:56:18 +00:00
|
|
|
$> psql -h "$PWD/data" -d postgres
|
2023-11-28 17:21:56 +00:00
|
|
|
```
|