Class: ReactOnRails::Dev::DatabaseChecker
- Inherits:
-
Object
- Object
- ReactOnRails::Dev::DatabaseChecker
- Defined in:
- lib/react_on_rails/dev/database_checker.rb
Overview
DatabaseChecker validates that the Rails database is properly set up before starting the development server.
This prevents confusing errors when running bin/dev on a fresh checkout or after database cleanup.
Checks performed:
-
Database exists and is accessible
-
Migrations are up to date (optional warning)
Can be disabled via:
-
Environment variable: SKIP_DATABASE_CHECK=true
-
CLI flag: bin/dev –skip-database-check
-
Configuration: ReactOnRails.configure { |c| c.check_database_on_dev_start = false }
Note: This check spawns a Rails runner process which adds ~1-2 seconds to startup. Disable it if this overhead is unacceptable for your workflow.
Class Method Summary collapse
-
.check_database(skip: false) ⇒ Boolean
Check if the database is set up and accessible.
Class Method Details
.check_database(skip: false) ⇒ Boolean
Check if the database is set up and accessible
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/react_on_rails/dev/database_checker.rb', line 32 def check_database(skip: false) return true if should_skip_check?(skip) result = run_database_check case result[:status] when :ok print_database_ok check_pending_migrations true when :error print_database_error(result[:error]) false when :not_rails_app ("bin/rails not found — skipping database check") true else (result[:error] || "unexpected status: #{result[:status]}") true end end |