https://github.com/zcubbs/pgc
🌱 pgc is a CLI that automates the initialization process of a PostgreSQL database.
https://github.com/zcubbs/pgc
config postgres
Last synced: about 2 months ago
JSON representation
🌱 pgc is a CLI that automates the initialization process of a PostgreSQL database.
- Host: GitHub
- URL: https://github.com/zcubbs/pgc
- Owner: zcubbs
- License: mit
- Created: 2023-10-17T07:44:53.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-17T08:50:24.000Z (over 2 years ago)
- Last Synced: 2025-08-22T06:00:19.539Z (11 months ago)
- Topics: config, postgres
- Language: Go
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `pgc` PostgreSQL Initializer
`pgc` is a CLI that automates the initialization process of a PostgreSQL database. It creates users, databases, assigns privileges, updates the `pg_hba.conf` file, and restarts the PostgreSQL service.
[](https://github.com/zcubbs/pgc/releases)

[](https://pkg.go.dev/github.com/zcubbs/pgc)
[](https://github.com/zcubbs/pgc/actions/workflows/lint.yaml)
[](https://github.com/zcubbs/pgc/actions/workflows/scan.yaml)

[](https://goreportcard.com/report/github.com/zcubbs/pgc)
[](https://github.com/zcubbs/pgc/graphs/contributors)
[](./LICENSE)
## Prerequisites
- A running PostgreSQL instance.
- A user with `CREATEDB` and `CREATEROLE` privileges.
- A user with `LOGIN` privileges.
## Installation
```bash
curl -sfL https://raw.githubusercontent.com/zcubbs/pgc/main/install.sh | bash
```
## Usage
```bash
pgc -c config.yaml
```
## Configuration
Edit the `config.yaml` file to set up the PostgreSQL configurations, users, databases, and privileges. Below are the configurable sections:
- `postgresql`: PostgreSQL connection details such as host, port, user, and password.
- `databases`: List of databases to be created along with their owners.
- `users`: List of users to be created along with their passwords.
- `privileges`: Privileges to be granted to users on specific databases.
- `pg_hba`: pg_hba configuration details.
- `pg_hba_conf_path`: Path to the `pg_hba.conf` file.
- `restart_cmd`: Command to restart the PostgreSQL service.
## Development
### Prerequisites
- [Go](https://golang.org/doc/install)
- [Task](https://taskfile.dev/#/installation)
### Run Test Using Docker
1. Build the Docker image:
```bash
docker build -t pgc . && docker run --rm --name pgc -p 5432:5432 pgc
```
the test config file `config.yaml` will be used.
## License
HuB is licensed under the [MIT](./LICENSE) license.