Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Allow to pass a connection to the `dbconsole` command #29358
Since 0a4f600, it's possible to specify a 3-level database configuration to gather connections by environment.
Have a nice day !
Jeremy, there is now a
Kasper, passing the environment as a regular argument is deprecated as you suggested ; this is certainly going to be easier for us to handle only the connection as a regular argument. Such flavor is not deprecated for the
Finally, there's a tiny fix attached with this pull request because if we are going to deprecate passing the environment as a regular argument, people may encounter issues as the
Thanks for the feedback guys ! :-)
Since 0a4f600, it's possible to specify a 3-level database configuration to gather connections by environment. The `dbconsole` command will try to look for a database configuration which points to the current environment but with such flavour, the environment key is flushed out so let's add the ability to specify the connection and pick `primary` by default to be consistent with Active Record.
People should rather rely on the `-e` or `--environment` options to specify in which environment they want to work. This will allow us to specify the connection to pick as a regular argument in the future.
Running the `console` and `dbconsole` commands with a regular argument as the environment's name automatically expand it to match an existing environment (e.g. dev for development). This feature wasn't available using the `--environment` (a.k.a `-e`) option.
I mistype `rails server production` instead of `rails server -e production` expecting to lunch a server in the production environment all the time. However, the signature of `rails server --help` is: ``` Usage: rails server [puma, thin etc] [options] ``` This means that the `production` argument is being interpreted as a Rack server handler like Puma, Thin or Unicorn. Should we argue for the `rails server production`? I'm not sure of the reasons, but the `rails console production` behavior was deprecated in: rails#29358, so parity with the existing `rails console production` usage may not hold anymore. In any case, this PR introduces an explicit option for the Rack servers configuration. The option is called `--using` (or `-u` for short) to avoid the `rails server --server` tantrum. The new interface of `rails server` is: ``` Usage: rails server [using] [options] Options: -p, [--port=port] # Runs Rails on the specified port - defaults to 3000. -b, [--binding=IP] # Binds Rails to the specified IP - defaults to 'localhost' in development and '0.0.0.0' in other environments'. -c, [--config=file] # Uses a custom rackup configuration. # Default: config.ru -d, [--daemon], [--no-daemon] # Runs server as a Daemon. -e, [--environment=name] # Specifies the environment to run this server under (development/test/production). -u, [--using=name] # Specifies the Rack server used to run the application (thin/puma/webrick). -P, [--pid=PID] # Specifies the PID file. # Default: tmp/pids/server.pid -C, [--dev-caching], [--no-dev-caching] # Specifies whether to perform caching in development. [--early-hints], [--no-early-hints] # Enables HTTP/2 early hints. ``` As a bonus, if you mistype the server to use, you'll get an auto-correction message: ``` $ rails s tin Could not find handler "tin". Maybe you meant "thin" or "cgi"? Run `rails server --help` for more options. ```