delete_in_batches 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c19c0abdd26b2ea2eea3ef9852d800f29077e7da89ecf3268068d4bc1c9a5032
4
- data.tar.gz: cfec1154bed9e3f406bb8fe601676204d6000f9fd569a1111c58e89d55c8953c
3
+ metadata.gz: 1f67278c3ef5c894ad549056a5f5b877e69742eb830b69aa1e468da9b109705f
4
+ data.tar.gz: 4aee16921a6b72a72b392a46bd03f69c6de5b939ffa9c1fd1f17f9f0d3933da6
5
5
  SHA512:
6
- metadata.gz: 5a1f174a03a098551d0542075d4a043ae523d17d3340802d010309c671f05a1a51c98b0ff1aba00adcce48a7715232e123b69a68d2fb3534440368c5fdfadfee
7
- data.tar.gz: 198d18d925e870567895eaf3373090b7155d4442c386ab37ad70e18efa4f9c0c5495f8034ad3070c7bf3c5c2a6bfb1c0a16228b7f62b402b7ec3472be4bf6644
6
+ metadata.gz: 386a6ed82ebdc123f9f286abeb4d0f15645a3d82ee013c48058ba9b230cfb1b05d4ccca2306bc0b06e3568c9e9cb5a22bd2f26c1cfb978ff083997111703e315
7
+ data.tar.gz: 2d17af5375794e73ed3e2c8a41a3b5b8fc96f2e8807905194970fc79b63e500df5799618d3daf8bf560cba619534be8d71fd131813deb43fe043e3c56d924259
@@ -0,0 +1,16 @@
1
+ ## 0.2.0 (2020-05-27)
2
+
3
+ - Improved Active Record integration
4
+ - Dropped support for Rails < 5
5
+
6
+ ## 0.1.0 (2018-09-05)
7
+
8
+ - Added support for MySQL
9
+
10
+ ## 0.0.2 (2014-01-27)
11
+
12
+ - Added missing dependency
13
+
14
+ ## 0.0.1 (2014-01-27)
15
+
16
+ - First release
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Andrew Kane
1
+ Copyright (c) 2014-2020 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -2,14 +2,16 @@
2
2
 
3
3
  :fire: The fastest way to delete 100k+ rows with ActiveRecord
4
4
 
5
- **Note: This gem is not needed in Rails 5+.** Instead, you can do:
5
+ [![Build Status](https://travis-ci.org/ankane/delete_in_batches.svg?branch=master)](https://travis-ci.org/ankane/delete_in_batches)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application’s Gemfile:
6
10
 
7
11
  ```ruby
8
- Tweet.where(user_id: 1).in_batches(of: 10000).delete_all
12
+ gem 'delete_in_batches'
9
13
  ```
10
14
 
11
- [![Build Status](https://travis-ci.org/ankane/delete_in_batches.svg?branch=master)](https://travis-ci.org/ankane/delete_in_batches)
12
-
13
15
  ## Slow
14
16
 
15
17
  ```ruby
@@ -19,7 +21,16 @@ Tweet.where(user_id: 1).delete_all
19
21
 
20
22
  The database performs the delete in a transaction - either all the records are deleted (query completes) or none are, due to [multiversion concurrency control](http://en.wikipedia.org/wiki/Multiversion_concurrency_control).
21
23
 
22
- ## Fast
24
+ ## Faster
25
+
26
+ ```ruby
27
+ Tweet.where(user_id: 1).in_batches(of: 10000).delete_all
28
+ # SELECT tweets.id FROM tweets WHERE user_id = 1 ORDER BY id LIMIT 1000
29
+ # DELETE FROM tweets WHERE user_id = 1 AND id IN (1, 2, 3, ...)
30
+ # ...
31
+ ```
32
+
33
+ ## Fastest
23
34
 
24
35
  ```ruby
25
36
  Tweet.where(user_id: 1).delete_in_batches
@@ -56,20 +67,6 @@ To delete all rows in a table, `TRUNCATE` is fastest.
56
67
  ActiveRecord::Base.connection.execute("TRUNCATE tweets")
57
68
  ```
58
69
 
59
- ## Installation
60
-
61
- Add this line to your application’s Gemfile:
62
-
63
- ```ruby
64
- gem "delete_in_batches"
65
- ```
66
-
67
- And then execute:
68
-
69
- ```sh
70
- bundle
71
- ```
72
-
73
70
  ## Contributing
74
71
 
75
72
  Everyone is encouraged to help improve this project. Here are a few ways you can help:
@@ -1,5 +1,8 @@
1
+ # dependencies
2
+ require "active_support"
3
+
4
+ # modules
1
5
  require "delete_in_batches/version"
2
- require "active_record"
3
6
 
4
7
  module DeleteInBatches
5
8
  def delete_in_batches(options = {})
@@ -19,4 +22,6 @@ module DeleteInBatches
19
22
  end
20
23
  end
21
24
 
22
- ActiveRecord::Base.send :extend, DeleteInBatches
25
+ ActiveSupport.on_load(:active_record) do
26
+ extend DeleteInBatches
27
+ end
@@ -1,3 +1,3 @@
1
1
  module DeleteInBatches
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delete_in_batches
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-05 00:00:00.000000000 Z
11
+ date: 2020-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,6 +86,7 @@ executables: []
86
86
  extensions: []
87
87
  extra_rdoc_files: []
88
88
  files:
89
+ - CHANGELOG.md
89
90
  - LICENSE.txt
90
91
  - README.md
91
92
  - lib/delete_in_batches.rb
@@ -102,15 +103,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
103
  requirements:
103
104
  - - ">="
104
105
  - !ruby/object:Gem::Version
105
- version: '2.2'
106
+ version: '2.4'
106
107
  required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  requirements:
108
109
  - - ">="
109
110
  - !ruby/object:Gem::Version
110
111
  version: '0'
111
112
  requirements: []
112
- rubyforge_project:
113
- rubygems_version: 2.7.7
113
+ rubygems_version: 3.1.2
114
114
  signing_key:
115
115
  specification_version: 4
116
116
  summary: The fastest way to delete 100k+ rows with ActiveRecord