aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/tasks/database_tasks.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* Dump schema cache for custom connectionKir Shatrov2017-01-011-0/+10
| | | | | | | | | Today `rake db:schema:cache:dump` only supports dumping cache for a single connection (`ActiveRecord::Base.connection`). This doesn't work for apps with multiple databases. This PR makes `DatabaseTasks` to provide an API for dumping schema cache for any connection.
* Remove deprecated #load_schema_forRafael Mendonça França2016-12-291-8/+0
|
* Make ActiveRecord structure load/dump configurableKir Shatrov2016-12-221-2/+12
| | | | | | | | Without this patch it's impossible to pass extra flags to mysqldump/pg_dump when running `rake db:structure:dump` or `load` The following config variables (`structure_load_flags` and `structure_dump_flags`) make it better configurable.
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* revises most Lint/EndAlignment offensesXavier Noria2016-08-071-3/+3
| | | | Some case expressions remain, need to think about those ones.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-25/+25
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-1/+1
|
* applies new string literal convention in activerecord/libXavier Noria2016-08-061-19/+19
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Add to_hash to specificationArthur Neves2016-05-251-1/+1
|
* Remove `name` from `establish_connection`Arthur Neves2016-05-241-1/+1
| | | | | Instead of passing a separete name variable, we can make the resolver merge a name on the config, and use that before creating the Specification.
* s/specification_name/connection_specification_nameArthur Neves2016-05-061-1/+1
|
* s/specification_id/specification_nameArthur Neves2016-05-051-1/+1
|
* Retrive the right pool for db tasksArthur Neves2016-05-051-2/+2
|
* Added notice when a database is successfully created or dropped.bogdanvlviv2016-04-171-2/+4
|
* Make 'migrate' clear the schema cache afterwardChris Arcand2016-03-241-0/+1
| | | | | | | | | | | | | | | | | | | Without clearing the caches afterward, removals done in migrations would not be reflected in a separate task in the same process. That is, given a table with a migration to remove a column, the schema cache would still reflect that a table has that in something such as the 'db:seed' task: `rake db:migrate db:seed` (A common thing to do in a script for a project ala `bin/setup`) vs `rake db:migrate && rake db:seed` (Two processes) The first would not reflect that the column was removed. The second would (cache reset).
* Creates development and test databases in db:migrate taskRafael Mendonça França2016-03-141-2/+1
| | | | | | | | | | | | | | | | This reverts a334425caff9b2140d5e99fcfc2eb8c4ab10bdfa. The main reason is that now the workflow is inconsistent when using spring. When using spring `RAILS_ENV` is always set, so only one database is created. This means that in development `bin/rake db:create` and `bundle exec rake db:create` have different results. It also breaks the `bin/setup` script since `bin/rake db:setup db:test:prepare` will fail.
* reestablish previous connection after creating all databasesAaron Patterson2016-02-231-0/+4
| | | | | | creating all databases mutates the connection pool. This patch restores the connection pool to the connection spec established before creating all databases. Fixes #23279
* match the environment variable name that actually checking and error messageyuuji.yaginuma2016-01-091-1/+1
| | | | | | The error message has become a `DISABLE_DATABASE_ENVIRONMENT_CHECK`, modified to match the error message. ref: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/migration.rb#L161
* Merge pull request #22967 from schneems/schneems/generic-metadataSean Griffin2016-01-081-0/+18
|\ | | | | Prevent destructive action on production database
| * Fixing tests and re-locating error checking.schneems2016-01-081-2/+2
| |
| * Use hash like syntax for InternalMetadataschneems2016-01-081-1/+1
| | | | | | | | Discussion: https://github.com/rails/rails/pull/22967#discussion_r49137035
| * Add EnvironmentMismatchErrorschneems2016-01-081-2/+11
| | | | | | Raise an error when a destructive action is made on a database where the current environment is different from the environment stored in the database.
| * Prevent destructive action on production databaseschneems2016-01-071-0/+9
| | | | | | | | | | | | | | This PR introduces a key/value type store to Active Record that can be used for storing internal values. It is an alternative implementation to #21237 cc @sgrif @matthewd. It is possible to run your tests against your production database by accident right now. While infrequently, but as an anecdotal data point, Heroku receives a non-trivial number of requests for a database restore due to this happening. In these cases the loss can be large. To prevent against running tests against production we can store the "environment" version that was used when migrating the database in a new internal table. Before executing tests we can see if the database is a listed in `protected_environments` and abort. There is a manual escape valve to force this check from happening with environment variable `DISABLE_DATABASE_ENVIRONMENT_CHECK=1`.
* | Refer to rails command instead of rake in a bunch of placesDavid Heinemeier Hansson2015-12-181-1/+1
|/ | | | Still more to do. Please assist!
* Exit with non-zero status when db:drop failsJay Hayes2015-10-201-1/+2
| | | | | | | | | | | * If the drop task fails for a reason other than the database not existing, processing should end. This is indicated by a non-zero exit status. * Since the backtrace is already printed to screen, we forgo printing it again by using an explicit call to `exit`. * :warning: This modifies the behavior of the db:create task slightly in that the stack trace is no longer printed by default. If the `--trace` option is used, it will print the trace _after_ the error message.
* Exit with non-zero status when db:create failsJay Hayes2015-10-201-1/+2
| | | | | | | | | | | * If the create task fails for a reason other than the database already existing, processing should end. This is indicated by a non-zero exit status. * Since the backtrace is already printed to screen, we forgo printing it again by using an explicit call to `exit`. * :warning: This modifies the behavior of the db:create task slightly in that the stack trace is no longer printed by default. If the `--trace` option is used, it will print the trace _after_ the error message.
* applies new doc guidelines to Active Record.Yves Senn2015-10-141-2/+2
| | | | | | | | | | | | | | | | | | | The focus of this change is to make the API more accessible. References to method and classes should be linked to make it easy to navigate around. This patch makes exzessiv use of `rdoc-ref:` to provide more readable docs. This makes it possible to document `ActiveRecord::Base#save` even though the method is within a separate module `ActiveRecord::Persistence`. The goal here is to bring the API closer to the actual code that you would write. This commit only deals with Active Record. The other gems will be updated accordingly but in different commits. The pass through Active Record is not completely finished yet. A follow up commit will change the spots I haven't yet had the time to update. /cc @fxn
* fix RDoc list markup in `DatabaseTasks`. [ci skip]Yves Senn2015-10-141-7/+7
|
* Remove dead codeRafael Mendonça França2015-09-091-6/+0
| | | | Usage was removed in 5c4495538b
* Allow global migrations_path configuration with using value from ↵Tobias Bielohlawek2015-09-071-1/+1
| | | | database_tasks instead of Migrator
* Fixes reference for schema_format to AR::Base from AS::BaseJames Cox2015-03-031-1/+1
|
* 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
* 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.
* 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-061-0/+2
| | | | | | 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
|/
* Revert "Merge pull request #15394 from ↵Rafael Mendonça França2014-07-021-2/+0
| | | | | | | | | | 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
|
* 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-121-0/+2
| | | | | | | | | 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`