aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-131-1/+0
| | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* Extract `truncate` and `truncate_tables` into database statementsRyuta Kamizono2019-03-171-12/+0
| | | | This is to easier make `truncate_tables` to bulk statements.
* Allow `truncate` for SQLite3 adapter and add `rails db:seed:replant` (#34779)Bogdan2019-03-041-0/+12
| | | | | | | | | | | | | * Add `ActiveRecord::Base.connection.truncate` for SQLite3 adapter. SQLite doesn't support `TRUNCATE TABLE`, but SQLite3 adapter can support `ActiveRecord::Base.connection.truncate` by using `DELETE FROM`. `DELETE` without `WHERE` uses "The Truncate Optimization", see https://www.sqlite.org/lang_delete.html. * Add `rails db:seed:replant` that truncates database tables and loads the seeds Closes #34765
* Add `Style/RedundantFreeze` to remove redudant `.freeze`Yasuo Honda2018-09-291-2/+2
| | | | | | | | | | | | | | | | | | | | | Since Rails 6.0 will support Ruby 2.4.1 or higher `# frozen_string_literal: true` magic comment is enough to make string object frozen. This magic comment is enabled by `Style/FrozenStringLiteralComment` cop. * Exclude these files not to auto correct false positive `Regexp#freeze` - 'actionpack/lib/action_dispatch/journey/router/utils.rb' - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb' It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333 Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed. * Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required - 'actionpack/test/controller/test_case_test.rb' - 'activemodel/test/cases/type/string_test.rb' - 'activesupport/lib/active_support/core_ext/string/strip.rb' - 'activesupport/test/core_ext/string_ext_test.rb' - 'railties/test/generators/actions_test.rb'
* Use -X when loading structure.sql via psqlJ Smith2018-09-271-1/+1
|
* Removed invalid -X flag for pg_dumpMatthias Winkelmann2018-09-271-1/+1
|
* Enable `Performance/UnfreezeString` copyuuji.yaginuma2018-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`. ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end Benchmark.ips do |x| x.report('+@') { +"" } x.report('dup') { "".dup } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] Warming up -------------------------------------- +@ 282.289k i/100ms dup 187.638k i/100ms Calculating ------------------------------------- +@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s Comparison: +@: 6775299.3 i/s dup: 3320400.7 i/s - 2.04x slower ```
* Ignore psqlrc files when executing psql commandsJ Smith2018-09-171-1/+1
| | | | | | psqlrc files can affect the execution of commands in ways that can hold up execution by blocking or otherwise cause unexpected side effects and should best be ignored when using psql programmatically.
* Turn on performance based copsDillon Welch2018-07-231-3/+1
| | | | | | | | | | | | | | | | Use attr_reader/attr_writer instead of methods method is 12% slower Use flat_map over map.flatten(1) flatten is 66% slower Use hash[]= instead of hash.merge! with single arguments merge! is 166% slower See https://github.com/rails/rails/pull/32337 for more conversation
* Fix `can't modify frozen String` error in `DatabaseTasks`yuuji.yaginuma2017-08-301-1/+1
| | | | | | | | | | | | | | | | | 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
|/
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* 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.
* 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.
* Make ActiveRecord structure load/dump configurableKir Shatrov2016-12-221-3/+6
| | | | | | | | 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
|
* Use Regexp#match? rather than Regexp#===Ryuta Kamizono2016-10-261-1/+1
| | | | 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.
* applies remaining conventions across the projectXavier Noria2016-08-061-6/+6
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-27/+27
|
* 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.
* 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.
* 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 deprecated pg_dump -i flagPaul Sadauskas2015-10-101-1/+1
|
* Merge pull request #17885 from starbelly/patch-1Yves Senn2015-08-111-8/+20
|\ | | | | | | | | | | | | Add method to run command-line db apps Conflicts: activerecord/CHANGELOG.md
| * Add run_cmd class method to ActiveRecord::Tasks::DatabaseTasksstarbelly2015-08-011-11/+12
|/ | | | | | | | | | - Added run_cmd() class method to dry up Kernel.system() messages within this namespace and avoid shell expansion by passing a list of arguments instead of a string - Update structure_dump, structure_load, and related tests units to pass a list of params instead of using a string to avoid shell expansion
* Avoid loading user's psqlrc when loading test structureJason Weathered2015-03-251-1/+1
|
* Add config.active_record.dump_schemas.Ryan Wallace2015-03-171-1/+9
| | | | | | | Fixes db:structure:dump when using schema_search_path and PostgreSQL extensions. Closes #17157.
* Using delegated connection methodJoshua Delsman2014-08-081-1/+1
|
* Fix loading a sql structure file on postgres when the file's path has ↵Kevin Mook2013-10-211-1/+1
| | | | whitespace in it
* Mute psql output when running rake db:schema:loadGodfrey Chan2013-04-301-1/+1
|
* Fix AR tests due to Mysql constant not being definedCarlos Antonio da Silva2013-01-121-1/+0
|
* Bring back "database already exists" messages when running rake tasksCarlos Antonio da Silva2013-01-121-0/+6
| | | | | | | | | | When running tasks such "rake db:setup", instead of showing messages like "db_development already exists", it was showing a big stack trace and a message "Couldn't create database for ..." with the configuration options, a very confusing message with a big trace. This brings back the functionality present in 3-2, showing the same message.
* Unify the collation API for the database adptersRafael Mendonça França2012-07-011-1/+1
|
* Extract collation tasks to database tasks.kennyj2012-07-011-0/+4
|
* Refactor db:structure:load task.kennyj2012-06-211-0/+5
|
* Refactor db:structure:dump task.kennyj2012-06-201-0/+22
|
* Refactor db:charset taskSimon Jefford2012-06-191-1/+5
| | | | | In a similar vein to Pat's work on create, drop etc, the db:charset task is now a one liner in databases.rake
* add :nodoc: to AR::Tasks and update to follow the coding conventionsFrancesco Rodriguez2012-06-181-44/+49
|
* Cleaning up after some warnings, adding slightly higher-level tests.Pat Allan2012-06-171-1/+3
|
* db:drop and some of db:test:purge.Pat Allan2012-06-171-6/+22
|
* db:create for PostgreSQL pulled out into a class.Pat Allan2012-06-171-0/+27