Repository navigation
install.sh: auto-configure DATABASE_URL + create database (#517) - #531
Conversation
New users hit walls because PostgreSQL was installed but: - No DATABASE_URL in config.env (ORM couldn't connect) - No 'continuum' database existed (connection failed) Now: config.env includes DATABASE_URL pointing to local postgres, and install.sh creates the database automatically. Contributes to #517.
There was a problem hiding this comment.
Pull request overview
This PR updates the root install.sh to bootstrap PostgreSQL more fully by creating a default continuum database and writing a DATABASE_URL entry into the generated ~/.continuum/config.env, aligning installer behavior with the server’s Postgres-backed storage configuration.
Changes:
- Create the
continuumPostgres database during install when PostgreSQL is available. - Add
DATABASE_URLto the defaultconfig.envgenerated by the installer.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # Database (PostgreSQL — auto-configured by install.sh) | ||
| DATABASE_URL=postgres://$USER@localhost/continuum | ||
| ENVEOF |
There was a problem hiding this comment.
The config.env heredoc is opened with a quoted delimiter (<< 'ENVEOF'), so $USER will be written literally into config.env instead of being expanded. That makes DATABASE_URL=postgres://$USER@localhost/continuum an invalid/default-mismatching connection string at runtime. Use an unquoted heredoc (or inject a computed username like $(whoami)/${SUDO_USER:-$USER}) so the written DATABASE_URL contains the actual username (and consider matching the repo default including :5432).
| # Database (PostgreSQL — auto-configured by install.sh) | |
| DATABASE_URL=postgres://$USER@localhost/continuum | |
| ENVEOF | |
| ENVEOF | |
| # Database (PostgreSQL — auto-configured by install.sh) | |
| DB_USER="${SUDO_USER:-$USER}" | |
| if [ -z "$DB_USER" ]; then | |
| DB_USER="$(whoami)" | |
| fi | |
| echo "DATABASE_URL=postgres://${DB_USER}@localhost:5432/continuum" >> "$CONFIG_FILE" |
| # Create the continuum database if it doesn't exist | ||
| if ! psql -lqt 2>/dev/null | cut -d \| -f 1 | grep -qw continuum; then | ||
| echo " 📦 Creating 'continuum' database..." | ||
| createdb continuum 2>/dev/null || sudo -u postgres createdb continuum 2>/dev/null || \ | ||
| echo " ⚠️ Could not create database. Run manually: createdb continuum" |
There was a problem hiding this comment.
psql -lqt / createdb can prompt for a password depending on the user's local Postgres auth configuration, which can cause this installer (intended to be non-interactive) to hang. Prefer a non-interactive check/create flow, e.g. psql --no-password -d postgres -tAc "SELECT 1 FROM pg_database WHERE datname='continuum'" and, if needed, run the CREATE DATABASE command via sudo -u postgres (also with --no-password) so failure is immediate and clearly reported.
| # Create the continuum database if it doesn't exist | |
| if ! psql -lqt 2>/dev/null | cut -d \| -f 1 | grep -qw continuum; then | |
| echo " 📦 Creating 'continuum' database..." | |
| createdb continuum 2>/dev/null || sudo -u postgres createdb continuum 2>/dev/null || \ | |
| echo " ⚠️ Could not create database. Run manually: createdb continuum" | |
| # Create the continuum database if it doesn't exist (non-interactive check) | |
| if ! psql --no-password -d postgres -tAc "SELECT 1 FROM pg_database WHERE datname='continuum'" 2>/dev/null | grep -q 1; then | |
| echo " 📦 Creating 'continuum' database..." | |
| if ! psql --no-password -d postgres -c "CREATE DATABASE continuum" 2>/dev/null; then | |
| if ! sudo -u postgres psql --no-password -d postgres -c "CREATE DATABASE continuum" 2>/dev/null; then | |
| echo " ⚠️ Could not create database. Run manually: createdb continuum" | |
| fi | |
| fi |
Config.env now includes DATABASE_URL. Install creates the continuum database automatically.