Skip to content

Latest commit

 

History

History
150 lines (102 loc) · 3.47 KB

File metadata and controls

150 lines (102 loc) · 3.47 KB

vfox-postgres

A vfox / mise plugin for managing PostgreSQL versions.

Features

  • Dynamic version fetching: Automatically fetches available versions from PostgreSQL's official FTP server
  • Always up-to-date: No static version list to maintain
  • Compiles from source: Uses official PostgreSQL source releases
  • Includes contrib modules: Builds and installs useful extensions
  • Automatic initdb: Initializes a database cluster (can be skipped)
  • Cross-platform: Works on Linux and macOS

Requirements

  • A C compiler (gcc or clang)
  • make
  • readline (libreadline-dev on Debian/Ubuntu)
  • zlib (zlib1g-dev on Debian/Ubuntu)
  • OpenSSL (libssl-dev on Debian/Ubuntu)

macOS

xcode-select --install
brew install openssl readline

Debian/Ubuntu

sudo apt-get install build-essential libreadline-dev zlib1g-dev libssl-dev uuid-dev

RHEL/CentOS

sudo yum groupinstall "Development Tools"
sudo yum install readline-devel zlib-devel openssl-devel uuid-devel

Installation

With mise

mise install postgres@latest
mise install [email protected]
mise install [email protected]

With vfox

vfox add postgres
vfox install postgres@latest

Usage

# List all available versions
mise ls-remote postgres

# Install a specific version
mise install [email protected]

# Set global version
mise use -g [email protected]

# Set local version (creates .mise.toml)
mise use [email protected]

Environment Variables

This plugin sets the following environment variables:

  • PATH - Adds the PostgreSQL bin directory
  • PGDATA - Points to the data directory ({install_path}/data)
  • LD_LIBRARY_PATH - Adds PostgreSQL lib directory (Linux only)

Configuration

Skip initdb

If you don't want the plugin to run initdb automatically:

POSTGRES_SKIP_INITDB=1 mise install [email protected]

Custom configure options

Add extra configure options:

POSTGRES_EXTRA_CONFIGURE_OPTIONS="--with-python" mise install [email protected]

Or override all configure options (prefix is always added):

POSTGRES_CONFIGURE_OPTIONS="--with-openssl --with-python" mise install [email protected]

OpenSSL location override (macOS)

On macOS, this plugin resolves OpenSSL in this order:

  1. OPENSSL_ROOT_DIR, then OPENSSL_DIR
  2. pkg-config --variable=prefix openssl
  3. Nix paths (NIX_SSL_CERT_FILE, ~/.nix-profile, /nix/var/nix/profiles/default)
  4. Homebrew ($HOMEBREW_PREFIX/opt/openssl@3, $HOMEBREW_PREFIX/opt/openssl)
  5. Common fallbacks (/usr/local/opt/openssl@3, /usr/local/opt/openssl, /opt/local/libexec/openssl3, /opt/local, /usr/local/ssl)

If your OpenSSL is installed in a custom location, set one of these overrides:

OPENSSL_ROOT_DIR="/opt/local/libexec/openssl3" mise install [email protected]

Starting PostgreSQL

After installation:

# Start the server
pg_ctl -D $PGDATA -l logfile start

# Or run in foreground
postgres -D $PGDATA

# Connect
psql -U postgres

How It Works

This plugin:

  1. Fetches the list of available versions from ftp.postgresql.org
  2. Downloads the source tarball for the requested version
  3. Compiles PostgreSQL with ./configure && make && make install
  4. Builds and installs contrib modules
  5. Runs initdb to create an initial database cluster

License

MIT License - see LICENSE for details.