aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/railties
Commit message (Collapse)AuthorAgeFilesLines
...
* db:migrate:status refactoring: Rewrite hand-crafted SQL query with ↵Viktar Basharymau2014-06-271-1/+1
| | | | ActiveRecord#pluck
* Use Array#flat_map and Array#grep in db:migrate:status taskViktar Basharymau2014-06-271-10/+10
| | | | It allows the code to be more declarative and elegant.
* Add explaining variables to db:migrate:statusViktar Basharymau2014-06-271-2/+2
|
* Replace String index juggling with Pathname goodness in db:fixtures:loadViktar Basharymau2014-06-271-1/+1
|
* db:fixtures:load refactoring: remove unnecessary loopViktar Basharymau2014-06-271-3/+1
| | | | | `ActiveRecord::FixtureSet.create_fixtures` can accept an array of fixture_files.
* Extract `fixture_files` variable in fixtures:load rake taskViktar Basharymau2014-06-271-1/+7
|
* Replace a bit of cryptic code in fixtures:load rake task with plain stupid RubyViktar Basharymau2014-06-271-1/+5
|
* Get rid of duplication in db:fixtures:{identify,load}Viktar Basharymau2014-06-271-11/+2
|
* db:fixtures:{identify,load} tasks respect AR::Tasks::DatabaseTasks.rootViktar Basharymau2014-06-271-2/+2
| | | | | | | Before this commit, if `ENV['FIXTURES_PATH']` was set, then `Rails.root` was used, otherwise the app used `ActiveRecord::Tasks::DatabaseTasks.root`. Now it is consistent.
* Simplify complex code in databases.rakeViktar Basharymau2014-06-271-2/+2
|
* add `bin/rake db:purge` task to empty the current database.Yves Senn2014-06-171-0/+11
|
* `bin/rake db:migrate:status` works with legacy migration numbers.Yves Senn2014-06-061-3/+4
| | | | | | | The migration numbers were normalized different ways. This left the task output in an inconsistent state. Closes #15538.
* rake railties:install:migrations respects the order of railtiesArun Agrawal2014-05-271-1/+1
| | | | This PR fixes #8930 and some stuff from #8985
* Return a non zero code when db has never been setup on statusPaul B2014-05-071-2/+1
|
* make `db:structure:load` listed with `rake -T`Greg Molnar2014-05-021-1/+1
|
* Replace trivial regexp with string or index, twice as fastKelley Reynolds2014-03-281-1/+1
|
* only dump schema information if migration table exists. Closes #14217Yves Senn2014-03-201-1/+2
|
* Merge pull request #14048 from pcreux/better-error-message-db-migrate-downCarlos Antonio da Silva2014-02-141-1/+1
|\ | | | | Add hint to error message of task db:migrate:down
| * Add hint to error message of task db:migrate:downPhilippe Creux2014-02-131-1/+1
| |
* | Add config to disable schema dump after migrationEmil Soman2014-02-061-1/+1
|/ | | | | | | | | * Add a config on Active Record named `dump_schema_after_migration` * Schema dump doesn't happen if the config is set to false * Set default value of the config to true * Set config in generated production environment file to false * Update configuration guide * Update CHANGELOG
* Ensure Active Record connection consistencyschneems2014-01-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* create/drop test and development databases only if RAILS_ENV is nilDamien Mathieu2014-01-081-2/+2
| | | | Closes #13625
* Add deprecation I accidentally missedJon Leighton2014-01-041-1/+1
|
* Automatically maintain test database schemaJon Leighton2014-01-021-17/+17
| | | | | | | | | | | | | | * Move check from generated helper to test_help.rb, so that all applications can benefit * Rather than just raising when the test schema has pending migrations, try to load in the schema and only raise if there are pending migrations afterwards * Opt out of the check by setting config.active_record.maintain_test_schema = false * Deprecate db:test:* tasks. The test helper is now fully responsible for maintaining the test schema, so we don't need rake tasks for this. This is also a speed improvement since we're no longer reloading the test database on every call to "rake test".
* Remove deprecation warning for FIXTURES_PATHPiotr Sarnacki2013-12-301-6/+0
| | | | | | | | FIXTURES_PATH has a bit different case than DatabaseTasks.fixtures_path, which was added along with deprecation. A use case for FIXTURES_PATH could be loading fixtures from a different directory just for a given test run. The implementation is fairly simple, so leaving it as it is won't hurt.
* Guarantee the connection resolver handles string valuesJosé Valim2013-12-231-10/+2
| | | | | | | | | This commit also cleans up the rake tasks that were checking for DATABASE_URL in different places. In fact, it would be nice to deprecate DATABASE_URL usage in the long term, considering the direction we are moving of allowing those in .yml files.
* db:test:clone and prepare must load environmentArthur Neves2013-12-141-3/+2
| | | | | | db:test:clone and db:test:prepare use ActiveRecord::Base. configurations, so we need to load the rails environment, otherwise the config wont be in place.
* Revert "Explicitly exit with status "1" for create and drop failures"Rafael Mendonça França2013-11-191-26/+10
| | | | | | | | | | This reverts commit 22f80ae57b26907f662b7fd50a7270a6381e527e. See https://github.com/rails/rails/commit/22f80ae57b26907f662b7fd50a7270a6381e527e#commitcomment-4640676 Conflicts: activerecord/CHANGELOG.md
* Merge pull request #12531 from iamvery/database-tasks-exit-statusRafael Mendonça França2013-11-151-10/+26
|\ | | | | | | | | | | | | Explicitly exit with status "1" for create and drop task failures Conflicts: activerecord/CHANGELOG.md
| * Explicitly exit with status "1" for create and drop failuresJay Hayes2013-11-111-10/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * A non-zero exit status allows subsequent shell commands to be chained together such as: `rake db:reset test:prepare && rspec && cap deploy` (if you're feeling brave :) * Any exceptions raised during the `create` and `drop` tasks are caught in order to print a "pretty" message to the user. Unfortunately doing so prevents rake from aborting with a non-zero exit status to the shell. * Therefore we re-raise the exceptions after the "pretty" message and re-catch them in the task. * From the task we explicitly exit with a non-zero status. This method was chosen (rather than just letting rake fail from the exception) so that the backtrace is suppressed and the output to stderr is unchanged. * Update activerecord CHANGELOG
* | Warnings removed for ruby trunkArun Agrawal2013-11-011-1/+1
|/ | | Same as 4d4ff531b8807ee88a3fc46875c7e76f613956fb
* newline at end of structure.sql fileChad Jolly2013-10-131-0/+1
|
* Revert "Merge pull request #12085 from valk/master"Santiago Pastorino2013-09-031-3/+1
| | | | | This reverts commit 15455d76c8d33b3767a61e0cdd2de0ff592098ef, reversing changes made to ffa56f73d5ae98fe0b8b6dd2ca6f0dffac9d9217.
* FIX reload! within rails console --sandbox causes undefined method rollback ↵Val Kotlarov Hoffman2013-08-301-1/+3
| | | | upon exiting [https://github.com/rails/rails/issues/11834]
* only reconnect if there was already an active connectionAaron Patterson2013-08-111-1/+4
| | | | | If you're using an in-memory database for the test database, reconnecting will lose all information that schema:load did for us.
* Improved grammar and replaced 'dbs' slang with 'databases'Prathamesh Sonpatki2013-06-271-3/+3
|
* Properly namespace DatabaseTasksPiotr Sarnacki2013-06-141-1/+1
|
* Use DatabaseTasks.env instead of Rails.env in databases.rakePiotr Sarnacki2013-06-141-1/+1
|
* the rake task `db:test:prepare` needs to load the configurationYves Senn2013-05-211-1/+1
| | | | Without loading the configuration the task will not perform any work.
* rake:db:test:prepare falls back to original environment after execution.markevich2013-05-021-3/+7
|
* Abort a rake task when missing db/structure.sql like `db:schema:load` task.kennyj2013-05-011-5/+3
|
* Use DatabaseTasks.fixtures_path instead of FIXTURES_PATH in db.rakePiotr Sarnacki2013-04-241-2/+19
| | | | | | This will allow to set fixtures path in global config easier, it should be not needed to use FIXTURES_PATH every time user wants to load fixtures.
* Don't require having Rails.application to run database tasksPiotr Sarnacki2013-04-241-15/+9
|
* Merge pull request #10258 from thenickcox/pending_migrations_pluralRafael Mendonça França2013-04-181-3/+3
|\ | | | | Fix subject-verb agreement in error msg (and other grammar stuff)
| * Fix subject-verb agreement in error msg (and other grammar stuff)thenickcox2013-04-171-3/+3
| |
* | Use db:test:load instead of db:test:load_schemaPiotr Sarnacki2013-04-161-1/+1
| | | | | | | | | | | | | | db:test:load task should be favored over db:test:load_schema, because it checks for chosen format (ActiveRecord::Base.schema_format). closes #10227
* | fix AP warning; remove unused variableVipul A M2013-04-091-1/+1
| |
* | just check pending migrations in the current environmentAaron Patterson2013-04-051-2/+2
| |
* | check pending migrations against the test dbAaron Patterson2013-04-031-11/+3
| |
* | ensure the schema checking is done in the dev connectionAaron Patterson2013-04-031-0/+8
|/