aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/tasks/sqlite_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-10/+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/+10
| | | | | | | | | | | | | * 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
* 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 ```
* Turn on performance based copsDillon Welch2018-07-231-7/+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>' ```
* 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
|
* 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
* 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
|
* 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-221-4/+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.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-6/+6
|
* applies new string literal convention in activerecord/libXavier Noria2016-08-061-5/+5
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* 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.
* Revert "Revert "Merge pull request #15394 from ↵Yves Senn2014-08-061-1/+5
| | | | | | morgoth/fix-automatic-maintaining-test-schema-for-sql-format"" This reverts commit 5c87b5c5248154cf8aa76cce9a24a88769de022d.
* Revert "Merge pull request #15394 from ↵Rafael Mendonça França2014-07-021-5/+1
| | | | | | | | | | morgoth/fix-automatic-maintaining-test-schema-for-sql-format" This reverts commit 46139d33c06715e74ad450428ece3ee84da98579, reversing changes made to 8f247871bb18b2e3036a05df5f62cbfe3b402586. Conflicts: activerecord/CHANGELOG.md
* Fixed automatic maintaining test schema to properly handle sql structure ↵Wojciech Wnętrzak2014-06-121-1/+5
| | | | | | | | | 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`
* let the sqlite task run without railsDamien Mathieu2013-08-071-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-4/+1
| | | | | | | | | | 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.
* Refactor db:structure:load task.kennyj2012-06-211-0/+5
|
* Refactor db:structure:dump task.kennyj2012-06-201-0/+5
|
* 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
* fix invalid syntax and sqlite rake failing testsFrancesco Rodriguez2012-06-181-2/+3
|
* add :nodoc: to AR::Tasks and update to follow the coding conventionsFrancesco Rodriguez2012-06-181-28/+31
|
* check if sqlite3 file exists before removeFrancesco Rodriguez2012-06-181-3/+3
|
* Rails is the default (but now override able) source for environment and path.Pat Allan2012-06-171-3/+7
|
* 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-0/+10
|
* db:create for PostgreSQL pulled out into a class.Pat Allan2012-06-171-3/+5
|
* db:create for MySQL now much cleaner.Pat Allan2012-06-171-0/+19