aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/tasks
Commit message (Collapse)AuthorAgeFilesLines
* Reduce string objects by using \ instead of + or << for concatenating stringsAkira Matsuda2017-01-121-2/+2
| | | | (I personally prefer writing one string in one line no matter how long it is, though)
* Remove unneeded requires at active recordRafael Mendonça França2017-01-031-2/+0
|
* 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
|
* Remove original_exception from ActiveRecord::StatementInvalidRafael Mendonça França2016-12-291-1/+1
|
* Remove try! usage in sqlite_database_tasks.Kasper Timm Hansen2016-12-291-2/+2
| | | | We try to not try! internally.
* Make ActiveRecord structure load/dump configurableKir Shatrov2016-12-224-11/+28
| | | | | | | | 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-292-2/+2
|
* Use Regexp#match? rather than Regexp#===Ryuta Kamizono2016-10-262-2/+2
| | | | Follow up to 99cf7558000090668b137085bfe6bcc06c4571dc.
* Fix Remaining Case-In-Assignment Statement FormattingAlex Kitchens2016-09-061-8/+9
| | | | | | | | | Recently, the Rails team made an effort to keep the source code consistent, using Ruboco (bb1ecdcc677bf6e68e0252505509c089619b5b90 and below). Some of the case statements were missed. This changes the case statements' formatting and is consistent with changes in 810dff7c9fa9b2a38eb1560ce0378d760529ee6b and db63406cb007ab3756d2a96d2e0b5d4e777f8231.
* Fix broken heredoc indentation caused by rubocop auto-correctRyuta Kamizono2016-09-031-1/+1
| | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But heredocs was still kept absolute position. This commit aligns heredocs indentation for consistency.
* revises most Lint/EndAlignment offensesXavier Noria2016-08-071-3/+3
| | | | Some case expressions remain, need to think about those ones.
* applies remaining conventions across the projectXavier Noria2016-08-061-6/+6
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-064-116/+116
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-1/+1
|
* applies new string literal convention in activerecord/libXavier Noria2016-08-064-71/+71
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* systematic revision of =~ usage in ARXavier Noria2016-07-231-1/+1
| | | | | Where appropriatei, prefer the more concise Regexp#match?, String#include?, String#start_with?, or String#end_with?
* Merge pull request #23301 from ppworks/improve_mysqldumpArthur Nogueira Neves2016-06-171-0/+1
|\ | | | | Improve mysqldump
| * Skip comments when exec mysqldumpNaoto Koshikawa2016-01-281-0/+1
| |
* | Merge pull request #24773 from ralinc/fix-silent-fail-on-psql-commandArthur Nogueira Neves2016-06-161-1/+2
|\ \ | | | | | | PostgreSQL: Fix db:structure:load silent failure on SQL error
| * | PostgreSQL: Fix db:structure:load silent failure on SQL errorRalin Chimev2016-05-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | The command line flag "-v ON_ERROR_STOP=1" should be used when invoking psql to make sure errors are not suppressed. Example: psql -v ON_ERROR_STOP=1 -q -f awesome-file.sql my-app-db Fixes #23818.
* | | 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.
* | Fix typo `--ssl-cipher`Ryuta Kamizono2016-03-061-1/+1
| | | | | | | | Follow up to #22543.
* | 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!
* | Remove legacy mysql adapterAbdelkader Boudih2015-12-171-2/+0
|/
* Fix rake db:structure:dump on Postgres when multiple schemas are used.Nick Muerdter2015-11-191-2/+2
| | | | | | | | | | | | | | | | | | If postgresql is being used and there are multiple schemas listed on the `schema_search_path`, then `structure.sql` dumps (triggered by `rake db:structure:dump` or `config.active_record.schema_format = :sql`) began failing in Rails 4.2.5. This is due to the changes made in https://github.com/rails/rails/pull/17885 The problem is that multiple schemas were getting getting passed to `Kernel.system` as a single, space delimited string argument (for example, "--schema=foo --schema=bar"). However, with the updated array style of calling `Kernel.system`, these need to be passed as separate arguments (for example, "--schema=foo", "--schema=bar"). If they get passed as a single string, then the underlying pg_dump program isn't sure how to interpret that single argument and you'll get an error reporting: "pg_dump: No matching schemas were found"
* Remove `DEFAULT_CHARSET` and `DEFAULT_COLLATION` in `MySQLDatabaseTasks`Ryuta Kamizono2015-11-021-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit f6ca7e4e75408bc42f515fc7206d6c6ff0dce7c6. The default collation of utf8 in MySQL is the `utf8_general_ci`, and this should not be changed. This is because, the better collation in the all locales is not exists, optimal collation in own application is not known other than themselves. The `utf8_unicode_ci` is known as Japanese killer in Japan, there are serious impacts in search of Japanese. MySQL implements the `utf8_unicode_ci` according to the Unicode Collation Algorithm (UCA) described at http://www.unicode.org/reports/tr10/, but the `utf8_unicode_ci` have only partial support for the UCA, only primary level key comparison implemented (also known as L1 (Base characters) comparison). Because L1 (Base characters) comparison does not distinguish between the presence or absence of the accent, if distinction of the accent is important there is a serious impact (e.g. Japanese). Example: ``` > SHOW CREATE TABLE `dicts`\G *************************** 1. row *************************** Table: dicts Create Table: CREATE TABLE `dicts` ( `word` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `meaning` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci 1 row in set (0.00 sec) > INSERT INTO `dicts` VALUES ('ハハ', 'mother'), ('パパ', 'father'); Query OK, 2 rows affected (0.00 sec) > SELECT * FROM `dicts` WHERE `word` = 'ハハ'; +--------+---------+ | word | meaning | +--------+---------+ | ハハ | mother | | パパ | father | +--------+---------+ 2 rows in set (0.00 sec) > CREATE UNIQUE INDEX `unique_index_word` ON `dicts`(`word`); ERROR 1062 (23000): Duplicate entry 'ハハ' for key 'unique_index_word' ``` We should omit the collation entirely rather than providing a default. Then the choice is the responsibility of the server and MySQL distribution.
* 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.
* Fix test of drop failureJay Hayes2015-10-201-1/+5
| | | | | | | * Previously the sqlite3 adapter could not "fail" on drop. Now an error is raised when no file exists. * Also updates purge to be resilient of drop failures. This is how purge is expected to behave.
* 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 deprecated pg_dump -i flagPaul Sadauskas2015-10-101-1/+1
|
* Merge pull request #20569 from theSteveMitchell/masterYves Senn2015-09-221-9/+18
|\ | | | | | | Check mysql structure_load for errors
| * Check response of structure_load for mysql_database_tasks and make ↵Steve Mitchell2015-09-181-9/+19
|/ | | | structure_dump consistent
* Merge pull request #20848 from ↵Arthur Nogueira Neves2015-09-141-1/+1
|\ | | | | | | | | deivid-rodriguez/fix_undefined_method_error_on_exception Fix undefined method error on exception