-
-
Notifications
You must be signed in to change notification settings - Fork 638
Open
Labels
Description
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:
- Buried errors: Database connection errors are hidden in the combined Foreman/Overmind logs
- Poor DX: Developers see the server "running" but page loads fail
- Unclear failure mode: No upfront indication that
db:setupordb:migrateis 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 successProposed Solution
Add a database check in ReactOnRails::Dev::ServerManager before starting processes:
-
Check if database exists
- Run a simple query like
ActiveRecord::Base.connection.execute('SELECT 1') - Catch connection errors
- Run a simple query like
-
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) -
Optional: Auto-setup flag
- Consider
bin/dev --setupto rundb:setupautomatically - Or prompt user: "Run db:setup now? [y/N]"
- Consider
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:resetordb:drop - New contributors getting started
- CI/development environment setup scripts