aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/tasks
Commit message (Collapse)AuthorAgeFilesLines
* Fix syntax warningSean Griffin2014-12-231-1/+1
| | | | This isn't Seattle.rb, @senny. ;)
* Replace deprecated `#load_schema` with `#load_schema_for`.Yves Senn2014-12-231-22/+19
|
* `db:structure:load` and `db:schema:load` no longer purge the database.Yves Senn2014-12-181-2/+0
| | | | | | | | | | | | | | | | | Closes #17945 `db:test:prepare` still purges the database to always keep the test database in a consistent state. This patch introduces new problems with `db:schema:load`. Prior to the introduction of foreign-keys, we could run this file against a non-empty database. Since every `create_table` containted the `force: true` option, this would recreate tables when loading the schema. However with foreign-keys in place, `force: true` wont work anymore and the task will crash. /cc @schneems
* activerecord: rake db:create shows underlying error message.Paul Annesley2014-11-041-0/+1
|
* Don't attempt to load the schema file in tests if none existsSean Griffin2014-10-311-2/+17
|
* let's warn with heredocsXavier Noria2014-10-281-3/+6
| | | | | | | | | | | | The current style for warning messages without newlines uses concatenation of string literals with manual trailing spaces where needed. Heredocs have better readability, and with `squish` we can still produce a single line. This is a similar use case to the one that motivated defining `strip_heredoc`, heredocs are super clean.
* schema loading rake tasks maintain database connection for current env.Yves Senn2014-09-031-0/+2
| | | | | | | | | | [Joshua Cody & Yves Senn] Closes #16757. Prior to this patch schema loading rake tasks had the potential to leak a connection to a different database. This had side-effects when rake tasks operating on the current connection (like `db:seed`) were chained.
* Forgot to set Migration.verbose at f8d9a51949d6f6cfcab7cc7d501e137836eb88dc ↵Akira Matsuda2014-08-301-1/+1
| | | | :bomb:
* Don't allow AR::Tasks::DatabaseTasks.migrate to mutate Migration.verbose valueAkira Matsuda2014-08-301-1/+3
| | | | This fixes random test failure in migrator_test.rb
* Avoid using heredoc for user warningsGodfrey Chan2014-08-281-4/+4
| | | | | | | | | | Using heredoc would enforce line wrapping to whatever column width we decided to use in the code, making it difficult for the users to read on some consoles. This does make the source code read slightly worse and a bit more error-prone, but this seems like a fair price to pay since the primary purpose for these messages are for the users to read and the code will not stick around for too long.
* Using delegated connection methodJoshua Delsman2014-08-081-1/+1
|
* schema rake tasks are specific about the configuration to act on.Yves Senn2014-08-061-3/+20
| | | | | | | | | | The rake tasks and the `DatabaseTakss` adapter classes used to assume a configuration at some places. This forced the rake tasks to establish a specific connection before calling into `load_schema`. After #15394 this started to cause issues because it could `purge` the wrong database before loading the schema.
* Revert "Revert "Merge pull request #15394 from ↵Yves Senn2014-08-062-1/+7
| | | | | | morgoth/fix-automatic-maintaining-test-schema-for-sql-format"" This reverts commit 5c87b5c5248154cf8aa76cce9a24a88769de022d.
* Add ActiveRecord::Tasks::DatabaseTasks.migrateJack Danger Canty2014-07-311-0/+10
| | | | | | This extracts the logic that was embedded in a Rake task into a static method. Bonus: the first test for `rake db:migrate`
* Merge pull request #16295 from kenn/no_stacktrace_drop_taskRafael Mendonça França2014-07-281-0/+2
|\ | | | | | | No verbose backtrace by db:drop when database does not exist.
| * No verbose backtrace by db:drop when database does not exist.Kenn Ejima2014-07-271-0/+2
|/
* fix, mysql `db:purge` respects `Rails.env`.Yves Senn2014-07-241-1/+1
| | | | | | | | | | | | | | | | | | | | Previously this method always established a connection to the test database. This resulted in buggy behavior when combined with other tasks like `bin/rake db:schema:load`. This was one of the reasons why #15394 (22e9a91189af2c4e6217a888e77f22a23d3247d1) was reverted: > I’ve replicated it on a new app by the following commands: 1) rails generate model post:title, 2) rake db:migrate, 3) rake db:schema:load, 4) rails runner ‘puts Post.first’. The last command goes boom. Problem is that rake db:schema:load wipes the database, and then doesn’t actually restore it. This is all on MySQL. There’s no problem with SQLite. -- DHH https://github.com/rails/rails/commit/22e9a91189af2c4e6217a888e77f22a23d3247d1#commitcomment-6834245
* Revert "Merge pull request #15394 from ↵Rafael Mendonça França2014-07-022-7/+1
| | | | | | | | | | morgoth/fix-automatic-maintaining-test-schema-for-sql-format" This reverts commit 46139d33c06715e74ad450428ece3ee84da98579, reversing changes made to 8f247871bb18b2e3036a05df5f62cbfe3b402586. Conflicts: activerecord/CHANGELOG.md
* Get rid of duplication in db:fixtures:{identify,load}Viktar Basharymau2014-06-271-1/+5
|
* add `bin/rake db:purge` task to empty the current database.Yves Senn2014-06-171-0/+12
|
* /mysql/i -> MySQL, Spell correct in continuation to #15555Akshay Vishnoi2014-06-141-1/+1
|
* Specifically talking about Rake the library [ci skip]Zachary Scott2014-06-131-2/+1
|
* Fixed automatic maintaining test schema to properly handle sql structure ↵Wojciech Wnętrzak2014-06-122-1/+7
| | | | | | | | | schema format. Additionally: * It changes `purge` task on `sqlite3` adapter to recreate database file, to be consistent with other adapters. * Adds `purge` step when loading from `schema.rb`
* use YAML.load_file in database tasks exampleRobin Tweedie2014-04-151-1/+1
| | | | | rather than YAML.load(File.read(path)). YAML.load_file is also used in guides/rails_guides/helper.rb since 2011, the only other precedent I could find.
* create/drop test and development databases only if RAILS_ENV is nilDamien Mathieu2014-01-081-1/+2
| | | | Closes #13625
* Automatically maintain test database schemaJon Leighton2014-01-021-3/+41
| | | | | | | | | | | | | | * 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".
* Cast env to symbol, fixes deprecation warningŁukasz Strzałkowski2013-12-251-1/+1
| | | | | | Warning: DEPRECATION WARNING: Passing a string to ActiveRecord::Base.establish_connection for a configuration lookup is deprecated, please pass a symbol (:development) instead.
* Guarantee the connection resolver handles string valuesJosé Valim2013-12-231-18/+1
| | | | | | | | | 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.
* Revert "Explicitly exit with status "1" for create and drop failures"Rafael Mendonça França2013-11-191-3/+0
| | | | | | | | | | 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-0/+3
|\ | | | | | | | | | | | | 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-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* | Fix loading a sql structure file on postgres when the file's path has ↵Kevin Mook2013-10-211-1/+1
| | | | | | | | whitespace in it
* | Convert Fixnum into String the port number in MySQLKenta Okamoto2013-10-181-1/+2
|/
* let the sqlite task run without railsDamien Mathieu2013-08-072-2/+3
|
* Remove FirebirdDatabaseTasks was deprecated, because this was provided by ↵kennyj2013-06-052-58/+0
| | | | 3rd-party.
* Remove SqlseverDatabaseTasks was deprecated, because this was provided by ↵kennyj2013-06-052-49/+0
| | | | 3rd-party.
* Remove OracleDatabaseTasks was deprecated, because this was provided by ↵kennyj2013-06-052-46/+0
| | | | 3rd-party.
* Mute psql output when running rake db:schema:loadGodfrey Chan2013-04-301-1/+1
|
* Abort a rake task when missing db/structure.sql like `db:schema:load` task.kennyj2013-05-011-0/+8
|
* Review DatabaseTasks docs [ci skip]Carlos Antonio da Silva2013-04-241-17/+17
|
* Use env == 'development' instead of env.development?Piotr Sarnacki2013-04-241-1/+1
| | | | | | It's simpler to assume that passed env is just a string without any extensions, especially when DatabaseTasks are intended to be used also without rails.
* Don't require Rails.env in order to use AR::Tasks::DatabaseTasksPiotr Sarnacki2013-04-241-6/+7
|
* Add some documentation to ActiveRecord::Tasks::DatabaseTasksPiotr Sarnacki2013-04-241-1/+29
| | | | | | This is a public class, which could be used directly in order to allow easier database management. Now it also contains settings, which will be used by databases.rake.
* Use DatabaseTasks.fixtures_path instead of FIXTURES_PATH in db.rakePiotr Sarnacki2013-04-241-1/+2
| | | | | | 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-0/+11
|
* Add deprecation message on Firebird / Sqlserver / Oracle database tasks.kennyj2013-04-033-0/+3
|
* Extract Oracle database tasks.kennyj2013-04-032-5/+50
|
* Extract Sqlserver database tasks.kennyj2013-04-032-1/+50
|
* Extract Firebird database tasks.kennyj2013-04-032-0/+56
|