aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/commands/dbconsole.rb
Commit message (Collapse)AuthorAgeFilesLines
* Fix rails dbconsole for jdbcmysql adapter.Gabriel Gilder and Jim Kingdon2014-05-051-1/+1
|
* Ensure Active Record connection consistencyschneems2014-01-091-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently Active Record can be configured via the environment variable `DATABASE_URL` or by manually injecting a hash of values which is what Rails does, reading in `database.yml` and setting Active Record appropriately. Active Record expects to be able to use `DATABASE_URL` without the use of Rails, and we cannot rip out this functionality without deprecating. This presents a problem though when both config is set, and a `DATABASE_URL` is present. Currently the `DATABASE_URL` should "win" and none of the values in `database.yml` are used. This is somewhat unexpected to me if I were to set values such as `pool` in the `production:` group of `database.yml` they are ignored. There are many ways that active record initiates a connection today: - Stand Alone (without rails) - `rake db:<tasks>` - ActiveRecord.establish_connection - With Rails - `rake db:<tasks>` - `rails <server> | <console>` - `rails dbconsole` We should make all of these behave exactly the same way. The best way to do this is to put all of this logic in one place so it is guaranteed to be used. Here is my prosed matrix of how this behavior should work: ``` No database.yml No DATABASE_URL => Error ``` ``` database.yml present No DATABASE_URL => Use database.yml configuration ``` ``` No database.yml DATABASE_URL present => use DATABASE_URL configuration ``` ``` database.yml present DATABASE_URL present => Merged into `url` sub key. If both specify `url` sub key, the `database.yml` `url` sub key "wins". If other paramaters `adapter` or `database` are specified in YAML, they are discarded as the `url` sub key "wins". ``` ### Implementation Current implementation uses `ActiveRecord::Base.configurations` to resolve and merge all connection information before returning. This is achieved through a utility class: `ActiveRecord::ConnectionHandling::MergeAndResolveDefaultUrlConfig`. To understand the exact behavior of this class, it is best to review the behavior in activerecord/test/cases/connection_adapters/connection_handler_test.rb though it should match the above proposal.
* Only build a ConnectionSpecification if requiredJosé Valim2013-12-241-1/+1
|
* Use the new Resolver API in dbconsoleJosé Valim2013-12-231-3/+2
|
* fixed rails dbconsole to support ENV['DATABASE_URL'].Huiming Teo2013-12-161-8/+5
|
* make "rails dbconsole" work with activerecord-postgis-adapterYanhaoYang2013-05-171-1/+1
|
* Don't use Rails.root since it is not available at this pointRafael Mendonça França2013-01-051-1/+1
|
* Move class method to instance in dbconsoleCarlos Antonio da Silva2013-01-041-2/+2
| | | | | This method doesn't need to be in the class, since it's only used only from the instance.
* This commit fixes issue #8628Mykola Kyryk2013-01-041-1/+9
| | | | | | | | | | | | Allow environment name to start with a substring of the default environment names. For example: tes, pro, prod, dev, devel, etc. Fixing identation. Adding test for Rails::Console.parse_arguments method. Fix issue 8628 for Rails::DBConsole.
* Refactor config abort message a bit for dbconsoleCarlos Antonio da Silva2012-11-181-7/+3
| | | | | | Remove not used variable. Remove config attr_reader causing warning. Fix indent in runner file.
* Fix rails db command with sqlite3 databaseCarlos Antonio da Silva2012-11-181-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | When using sqlite3 it was attempting to find the database file based on Rails.root, the problem is that Rails.root is not always present because we try to first manually load "config/database.yml" instead of loading the entire app, to make "rails db" faster. This means that when we're in the root path of the app, calling "rails db" won't allow us to use Rails.root, making the command fail for sqlite3 with the error: ./rails/commands/dbconsole.rb:62:in `start': undefined method `root' for Rails:Module (NoMethodError) The fix is to simply not pass any dir string to File.expand_path, which will make it use the current directory of the process as base, or the root path of the app, which is what we want. When we are in any other subdirectory, calling "rails db" should work just fine, because "config/database.yml" won't be found, thus "rails db" will fallback to loading the app, making Rails.root available. Closes #8257.
* Removing warning : assigned but unused variableArun Agrawal2012-11-101-1/+1
|
* Support MySQL SSL in rails dbconsole.needfeed2012-09-101-1/+6
|
* Fix various bugs with console arguments.Sam Oliver2012-05-301-62/+75
| | | | Allow hyphens in environment names again.
* Fix `rails db -h` and cosmetic fixes in usage bannersAlexey Vakhov2012-05-221-1/+6
| | | | | | | Ruby tries to use '-h' as short version of '--header' by default https://github.com/ruby/ruby/blob/trunk/lib/optparse.rb#L1372-1381. To force `rails db -h` prints an usage message we should add the `-h` options explicitly.
* Use relative path to sqlite3 db in `rails db` commandAlexey Vakhov2012-05-221-1/+1
| | | | | | | | | | Rails uses sqlit3 db file with a path relative to the rails root. It allows to execute server not from rails root only. For example you can fire `./spec/dummy/script/rails s` to start dummy application server if you develop some engine gem. Now the `rails db` command uses relative paths also and you can explore your dummy db via `./spec/dummy/script/rails db` command.
* More faster rails dbconsoleDmitry Vorotilin2012-05-061-10/+28
|
* Add Rails::DBConsole testsAlexey Vakhov2012-05-021-22/+34
|
* No need to require psych since require yaml does that.Rafael Mendonça França2012-01-041-1/+0
|
* No need to use rescue block to require psychRafael Mendonça França2012-01-041-6/+1
|
* dbconsole: Use the app's database_configuration instead of duplicating code.Dieter Komendera2011-12-141-1/+1
|
* Remove the -h option to dbconsole which is the shorter form of --headerVijay Dev2011-11-221-1/+1
| | | | | | This is done since the -h option to dbconsole hides the conventional -h for help and forces users to use --help to see the usage options for dbconsole.
* Corrected dbconsole usage message.2011-04-121-1/+1
|
* Accept 'postgres' as a PostgreSQL driver name in dbconsole for non-AR ORMs ↵Akira Matsuda2011-02-011-1/+1
| | | | | | | | like DataMapper and Sequel [#6180 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* "rails dbconsole t" must not load "production" but "test"Akira Matsuda2011-01-311-1/+1
| | | | | | [#6293 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* load and prefer psych as the YAML parser when it is availableAaron Patterson2011-01-211-0/+6
|
* Config is deprecated on 1.8.8 and 1.9.3 use RbConfigSantiago Pastorino2010-08-231-1/+1
|
* add support for mysql2 adapter to dbconsoleBrian Lopez2010-05-041-2/+2
| | | | | | [#4532 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Make db console work for all versions of ruby on Windows.unknown2010-04-261-1/+2
| | | | | | [#3999 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Make script/dbconsole work with oracle (sqlplus ↵Edgars Beigarts2010-03-261-0/+12
| | | | | | <username>[/<password>][@<connect_identifier>]) [#3773 state:resolved]
* Make script/dbconsole work again [#3690 state:resolved]Sam Granieri2010-01-161-2/+2
| | | | Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Get everyone running on Rails.env and fix the broken environment settings ↵David Heinemeier Hansson2010-01-111-1/+5
| | | | for script/console and script/dbconsole
* Have script/* and Rakefile use the application objectCarlhuda2009-11-241-3/+7
|
* Refactor script/dbconsole into an objectCarlhuda2009-11-241-80/+89
|
* Deprecate RAILS_ROOT in favor of Rails.root (which proxies to the ↵Carl Lerche2009-10-161-1/+1
| | | | application's object root)
* Move railties/lib/* into railties/lib/*Yehuda Katz + Carl Lerche2009-09-241-0/+87