aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/tasks
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #30414 from bogdanvlviv/clear-mysql_database_tasksRafael França2017-11-091-47/+0
|\ | | | | Simplify implementation of `MySQLDatabaseTasks`
| * Simplify implementation of `MySQLDatabaseTasks`bogdanvlviv2017-10-301-45/+0
| | | | | | | | | | | | Don't process MySQL ERROR 1045, raise error instead Make behavior of `MySQLDatabaseTasks` more consistent with behavior of `PostgreSQLDatabaseTasks`
| * Raise error if unsupported charset for mysqlbogdanvlviv2017-10-301-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `blog$ bin/rails db:create` Before: ``` Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf42", "pool"=>5, "username"=>"root", "password"=>nil, "socket"=>"/var/run/mysqld/mysqld.sock", "database"=>"blog_development"}, {:charset=>"utf42"} (If you set the charset manually, make sure you have a matching collation) Created database 'blog_development' Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf42", "pool"=>5, "username"=>"root", "password"=>nil, "socket"=>"/var/run/mysqld/mysqld.sock", "database"=>"blog_test"}, {:charset=>"utf42"} (If you set the charset manually, make sure you have a matching collation) Created database 'blog_test' ``` After: ``` Unsupported charset: '"utf42"' Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf42", "pool"=>5, "username"=>"root", "password"=>nil, "socket"=>"/var/run/mysqld/mysqld.sock", "database"=>"blog_development"} rails aborted! Mysql2::Error: Unsupported charset: '"utf42"' ... (stack trace) ... bin/rails:4:in `<main>' Tasks: TOP => db:create (See full trace by running task with --trace) ``` Closes #29683 Related to #27398
* | Fix `bin/rails db:migrate` with specified `VERSION`bogdanvlviv2017-11-061-3/+12
|/ | | | | | Ensure that `bin/rails db:migrate` with specified `VERSION` reverts all migrations only if `VERSION` is `0`. Raise error if target migration doesn't exist.
* [Active Record] require => require_relativeAkira Matsuda2017-10-211-1/+1
| | | | This basically reverts 9d4f79d3d394edb74fa2192e5d9ad7b09ce50c6d
* `ActiveRecord::Tasks::DatabaseTasks.load_schema` has always to establish ↵bogdanvlviv2017-10-151-3/+3
| | | | | | | | | | | | database connection When load schema from `structure.sql`, database connection isn't established. `ActiveRecord::Tasks::DatabaseTasks.load_schema` has to establish database connection since it executes ``` ActiveRecord::InternalMetadata.create_table ActiveRecord::InternalMetadata[:environment] = environment ```
* Fix `bin/rails db:setup` and `bin/rails db:test:prepare` create wrong ↵bogdanvlviv2017-10-151-7/+8
| | | | | | | | | | | | | | | | | | | | | | ar_internal_metadata's data for a test database. Before: ``` $ RAILS_ENV=test rails dbconsole > SELECT * FROM ar_internal_metadata; key|value|created_at|updated_at environment|development|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679 ``` After: ``` $ RAILS_ENV=test rails dbconsole > SELECT * FROM ar_internal_metadata; key|value|created_at|updated_at environment|test|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679 ``` Fixes #26731.
* Fix `can't modify frozen String` error in `DatabaseTasks`yuuji.yaginuma2017-08-302-2/+2
| | | | | | | | | | | | | | | | | Without this, `db:structure:dump` task raises an error as follwing: ``` can't modify frozen String activerecord/lib/active_record/tasks/sqlite_database_tasks.rb:77:in `run_cmd_error' activerecord/lib/active_record/tasks/sqlite_database_tasks.rb:72:in `run_cmd' activerecord/lib/active_record/tasks/sqlite_database_tasks.rb:52:in `structure_dump' activerecord/lib/active_record/tasks/database_tasks.rb:219:in `structure_dump' activerecord/lib/active_record/railties/databases.rake:279:in `block (3 levels) in <main>' railties/lib/rails/commands/rake/rake_command.rb:23:in `block in perform' railties/lib/rails/commands/rake/rake_command.rb:20:in `perform' railties/lib/rails/command.rb:48:in `invoke' railties/lib/rails/commands.rb:18:in `<main>' ```
* Merge pull request #30159 from allcentury/dump-temp-file-permissionsRafael França2017-08-111-1/+1
|\ | | | | Use copy to preserve file permissions
| * Use copy to preserve file permissionsAnthony Ross2017-08-091-1/+1
| |
* | Update database duplication checkzverok2017-08-111-1/+1
|/
* Avoid modifying frozen string in check_schema_fileEugene Kenny2017-07-231-1/+1
| | | | | | This was missed when the frozen string literal pragma was added to this file because the string is only modified when running in the context of a full Rails app, which wasn't covered by the test suite.
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-194-0/+8
|
* * Don't eagerly require Rails' minitest plugin.Kasper Timm Hansen2017-07-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | By making the Rails minitest behave like a standard minitest plugin we're much more likely to not break when people use other minitest plugins. Like minitest-focus and pride. To do this, we need to behave like minitest: require files up front and then perform the plugin behavior via the at_exit hook. This also saves us a fair bit of wrangling with test file loading. Finally, since the environment and warnings options have to be applied as early as possible, and since minitest loads plugins at_exit, they have to be moved to the test command. * Don't expect the root method. It's likely this worked because we eagerly loaded the Rails minitest plugin and that somehow defined a root method on `Rails`. * Assign a backtrace to failed exceptions. Otherwise Minitest pukes when attempting to filter the backtrace (which Rails' backtrace cleaner then removes). Means the exception message test has to be revised too. This is likely caused by the rails minitest plugin now being loaded for these tests and assigning a default backtrace cleaner.
* Merge branch 'master' into require_relative_2017Xavier Noria2017-07-021-1/+1
|\
| * Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-024-4/+0
| | | | | | | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
| * Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-024-0/+4
| |\ | | | | | | | | | Enforce frozen string in Rubocop
| | * Enforce frozen string in RubocopKir Shatrov2017-07-014-0/+4
| | |
| * | Merge pull request #29506 from pat/frozen-string-literalsMatthew Draper2017-07-021-1/+1
| |\ \ | | |/ | |/| | | | Make ActiveSupport frozen-string-literal friendly.
| | * Make ActiveRecord frozen string literal friendly.Pat Allan2017-06-201-1/+1
| | |
* | | [Active Record] require => require_relativeAkira Matsuda2017-07-011-1/+1
|/ /
* | PR ReviewEdouard CHIN2017-06-211-2/+2
| |
* | pass `structure_dump_flags` / `structure_load_flags` options before any other:Edouard CHIN2017-06-211-2/+2
|/ | | | | | | - On Mysql, some command line options that affect option-file handling such as `--no-defaults` have to be passed before any other options - Modified rails to pass them right after the `mysql` command - Ref https://dev.mysql.com/doc/refman/5.7/en/option-file-options.html and https://bugs.mysql.com/bug.php?id=83386 - Ref #27437
* Should use `quote` for a string literalRyuta Kamizono2017-06-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Follow up of #29077. Before: ```sql SELECT sql FROM sqlite_master WHERE tbl_name NOT IN ("foo") ORDER BY tbl_name, type DESC, name ``` After: ```sql SELECT sql FROM sqlite_master WHERE tbl_name NOT IN ('foo') ORDER BY tbl_name, type DESC, name ``` > If a keyword in double quotes (ex: "key" or "glob") is used in a context where it cannot be resolved to an identifier but where a string literal is allowed, then the token is understood to be a string literal instead of an identifier. http://www.sqlite.org/lang_keywords.html
* Fix a RuboCop offences using `rubocop -a`Koichi ITO2017-05-241-3/+3
|
* Improvements for SQLite rake task.Guillermo Iguaran2017-05-151-7/+18
| | | | | | * Use NOT IN in SQL query * Quote table names propertly * Use array form of command invocation
* Respect 'ignore_tables' in SQLite structure dumpGuillermo Iguaran2017-05-151-1/+10
|
* Respect 'ignore_tables' in MySQL structure dumpGuillermo Iguaran2017-05-151-0/+6
|
* Respect `ignore_tables` in Postgres structure dumpRusty Geldmacher2017-05-151-0/+6
| | | | | | When using `sql` as the schema format, or even just doing `rake db:structure:dump`, it would be good to respect the list of ignored tables that has been configured.
* Defer loading each DB Tasks class from AR DatabaseTasksAkira Matsuda2017-05-111-6/+6
| | | | | | Because we don't need to load tasks for DBs that we don't use for the current app. Also, these Tasks classes load AR::Base in their class level, and so immediately kick :active_record on_load hooks. This used to happen when we were loading tasks, not when we run a task.
* Refactor AR::Tasks::DatabaseTasks::migratebogdanvlviv2017-04-261-1/+1
| | | | | Set consistent type cast ENV["VERBOSE"]: ENV["VERBOSE"] is true if it not equal "false"
* Fix quoting in db:create grant all statement.Rune Schjellerup Philosof2017-04-201-1/+1
| | | | | | The database name used in the test would have actually shown this if it had tried to execute on a real Mysql instead of being stubbed out (dashes in database names needs quotes).
* Fixes #28359Philippe Guay2017-03-261-1/+3
| | | | | | | | | | | | | | | | Add stronger assertions to rake migration tasks to make sure the user is providing a numeric VERSION An empty string was getting converted to version = 0. This would in turn pass the presence check. Address linting warning Add test for rake task and refactor code to meet expectations In particular passing VERSION=0 should not raise an error. Addressed Comments for PR #28485. Trimmed empty lines + change of wording for error message Adjust test for change of wording in error message Change condition to follow rails idioms
* Only remove comments before the first statementAri Pollak2017-02-241-4/+9
|
* Drop comments from structure.sql in postgresqlAri Pollak2017-02-241-0/+15
| | | | Fixes #28153.
* 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
|