diff options
author | Freya Murphy <freya@freyacat.org> | 2024-12-23 22:14:44 -0500 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-12-23 22:14:44 -0500 |
commit | 45b58da72187a7b1ed4d75fc25bf5dd59a86a9c4 (patch) | |
tree | 721d43e663d0b9d7c15ebc4b180ba709e9e0f9c3 /bin/psql | |
parent | lang null check (diff) | |
download | crimson-45b58da72187a7b1ed4d75fc25bf5dd59a86a9c4.tar.gz crimson-45b58da72187a7b1ed4d75fc25bf5dd59a86a9c4.tar.bz2 crimson-45b58da72187a7b1ed4d75fc25bf5dd59a86a9c4.zip |
rework tooling to make environement loading easier
Diffstat (limited to 'bin/psql')
-rwxr-xr-x | bin/psql | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/bin/psql b/bin/psql new file mode 100755 index 0000000..932f65d --- /dev/null +++ b/bin/psql @@ -0,0 +1,40 @@ +#!/bin/sh +### CRIMSON --- A simple PHP framework. +### Copyright © 2024 Freya Murphy <contact@freyacat.org> +### +### This file is part of CRIMSON. +### +### CRIMSON is free software; you can redistribute it and/or modify it +### under the terms of the GNU General Public License as published by +### the Free Software Foundation; either version 3 of the License, or (at +### your option) any later version. +### +### CRIMSON is distributed in the hope that it will be useful, but +### WITHOUT ANY WARRANTY; without even the implied warranty of +### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +### GNU General Public License for more details. +### +### You should have received a copy of the GNU General Public License +### along with CRIMSON. If not, see <http://www.gnu.org/licenses/>. + +# `psql` +# This is an alias for running +# $ `compose` exec postgres psql -U $POSTGRES_USER $POSTGRES_DB. +# +# When working on a crimson project, you will likely have to lurk within the +# database at times. This makes it nicer enter it since you dont have to type +# the full command. :) + +# Make sure errors fail to avoid nasal demons +set -e + +# ========================================================= LOAD ENVIRONMENT == +# We need to load the environment variables provided by crimson and the user +# making the project. +SCRIPT_DIR="$(dirname "$0")" +source "$SCRIPT_DIR/setup_env" + +# ================================================================ BOOTSTRAP == +# Load `base.env` and `.env`, then launch psql in docker. + +$SCRIPT_DIR/compose exec postgres psql -U "${POSTGRES_USER}" "${POSTGRES_DB}" "$@" |