Skip to content

install.sh: auto-configure DATABASE_URL + create database (#517) - #531

Merged
joelteply merged 1 commit into
mainfrom
fix/install-database-url
Mar 26, 2026
Merged

joelteply merged 1 commit into
mainfrom
fix/install-database-url

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Config.env now includes DATABASE_URL. Install creates the continuum database automatically.

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.
Copilot AI review requested due to automatic review settings March 26, 2026 16:21
@joelteply
joelteply merged commit 06106a4 into main Mar 26, 2026
3 of 4 checks passed
@joelteply
joelteply deleted the fix/install-database-url branch March 26, 2026 16:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 continuum Postgres database during install when PostgreSQL is available.
  • Add DATABASE_URL to the default config.env generated by the installer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread install.sh
Comment on lines +197 to 200

# Database (PostgreSQL — auto-configured by install.sh)
DATABASE_URL=postgres://$USER@localhost/continuum
ENVEOF

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
# 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"

Copilot uses AI. Check for mistakes.
Comment thread install.sh
Comment on lines +134 to +138
# 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"

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# 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

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants