Skip to content

bin/dev should check database setup before starting server #2099

@justin808

Description

@justin808

Problem

When running bin/dev on a fresh checkout or after database cleanup, the script starts all services (Rails server, Webpack dev server, etc.) without checking if the database is set up. This leads to:

  1. Buried errors: Database connection errors are hidden in the combined Foreman/Overmind logs
  2. Poor DX: Developers see the server "running" but page loads fail
  3. Unclear failure mode: No upfront indication that db:setup or db:migrate is needed

Current Behavior

$ bin/dev
# Server starts, processes launch
# Rails server fails with database errors buried in logs
# Webpack keeps running, giving false impression of success

Proposed Solution

Add a database check in ReactOnRails::Dev::ServerManager before starting processes:

  1. Check if database exists

    • Run a simple query like ActiveRecord::Base.connection.execute('SELECT 1')
    • Catch connection errors
  2. Provide clear guidance

    ❌ Database not set up!
    
    Run one of these commands first:
      • bin/rails db:setup     (for new setup)
      • bin/rails db:migrate   (if database exists)
    
  3. Optional: Auto-setup flag

    • Consider bin/dev --setup to run db:setup automatically
    • Or prompt user: "Run db:setup now? [y/N]"

Implementation Location

lib/react_on_rails/dev/server_manager.rb - add check in start method before launching processes.

Benefits

  • Better DX: Clear error message upfront instead of buried in logs
  • Faster debugging: Developers know exactly what to do
  • Prevents confusion: No false impression that server is working

Related

This is especially important for:

  • Fresh repository clones
  • After running db:reset or db:drop
  • New contributors getting started
  • CI/development environment setup scripts

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions