gindex 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +7 -1
- data/LICENSE.txt +22 -0
- data/README.md +14 -2
- data/lib/generators/index/index_generator.rb +17 -17
- data/lib/generators/index/templates/{index_migration.rb → index_migration.rb.tt} +1 -1
- data/lib/gindex/version.rb +1 -1
- metadata +12 -16
- data/.gitignore +0 -9
- data/Gemfile +0 -4
- data/Rakefile +0 -1
- data/gindex.gemspec +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 35cce2217af3e0865848afdd61cb2a54ff7970ec47236aa577e0b50701532869
|
4
|
+
data.tar.gz: d8b1640375ff1a053d49d6bc6c766dc8f68befd0f5fddd36308622d2c92cae5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca3037522cf1b9dfa8d02fad92f781ceab8cc8d120bfb769bc7e373544b06c706385823f9f49c83759844a259010edffeafd3fbd86aff5b9c86a3b3704465b38
|
7
|
+
data.tar.gz: 9a41396ce868f949d39c99c93372eabb9c85eeb3572dbc2303d3b97eb1ae352309004610f0c5e298911bc267c33437879c376c96bd39968c4fe9ecf40b90680f
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015-2019 Andrew Kane
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -2,13 +2,25 @@
|
|
2
2
|
|
3
3
|
:speedboat: Instant **concurrent** index migrations for Rails
|
4
4
|
|
5
|
-
```
|
5
|
+
```sh
|
6
6
|
rails g index users email
|
7
7
|
```
|
8
8
|
|
9
|
-
|
9
|
+
generates:
|
10
10
|
|
11
11
|
```ruby
|
12
|
+
class AddIndexOnEmailToUsers < ActiveRecord::Migration[6.0]
|
13
|
+
disable_ddl_transaction!
|
14
|
+
|
15
|
+
def change
|
16
|
+
add_index :users, [:email], algorithm: :concurrently
|
17
|
+
end
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
Also works with multi-column indexes
|
22
|
+
|
23
|
+
```sh
|
12
24
|
rails g index deliveries store_id delivered_at
|
13
25
|
```
|
14
26
|
|
@@ -1,30 +1,30 @@
|
|
1
|
-
require "rails/generators/
|
1
|
+
require "rails/generators/active_record"
|
2
2
|
|
3
3
|
class IndexGenerator < Rails::Generators::Base
|
4
|
-
include
|
5
|
-
|
6
|
-
source_root File.expand_path("../templates", __FILE__)
|
4
|
+
include ActiveRecord::Generators::Migration
|
5
|
+
source_root File.join(__dir__, "templates")
|
7
6
|
|
8
7
|
argument :table, type: :string
|
9
8
|
argument :columns, type: :array
|
10
9
|
|
11
|
-
# Implement the required interface for Rails::Generators::Migration.
|
12
|
-
def self.next_migration_number(dirname) #:nodoc:
|
13
|
-
next_migration_number = current_migration_number(dirname) + 1
|
14
|
-
if ::ActiveRecord::Base.timestamped_migrations
|
15
|
-
[Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
|
16
|
-
else
|
17
|
-
"%.3d" % next_migration_number
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
10
|
def copy_migration
|
22
|
-
|
11
|
+
migrate_path = ActiveRecord::Tasks::DatabaseTasks.migrations_paths.first
|
12
|
+
migration_template "index_migration.rb", "#{migrate_path}/add_index_on_#{columns.join('_and_')}_to_#{table}.rb"
|
23
13
|
end
|
24
14
|
|
25
15
|
def migration_version
|
26
|
-
|
27
|
-
|
16
|
+
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
17
|
+
end
|
18
|
+
|
19
|
+
def table_str
|
20
|
+
table.to_sym.inspect
|
21
|
+
end
|
22
|
+
|
23
|
+
def column_str
|
24
|
+
if columns.size == 1
|
25
|
+
columns.first.to_sym.inspect
|
26
|
+
else
|
27
|
+
columns.map(&:to_sym).inspect
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -2,6 +2,6 @@ class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version
|
|
2
2
|
disable_ddl_transaction!
|
3
3
|
|
4
4
|
def change
|
5
|
-
add_index <%=
|
5
|
+
add_index <%= table_str %>, <%= column_str %>, algorithm: :concurrently
|
6
6
|
end
|
7
7
|
end
|
data/lib/gindex/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gindex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
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: '
|
26
|
+
version: '5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,24 +53,21 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description:
|
56
|
-
email:
|
57
|
-
- andrew@chartkick.com
|
56
|
+
email: andrew@chartkick.com
|
58
57
|
executables: []
|
59
58
|
extensions: []
|
60
59
|
extra_rdoc_files: []
|
61
60
|
files:
|
62
|
-
- ".gitignore"
|
63
61
|
- CHANGELOG.md
|
64
|
-
-
|
62
|
+
- LICENSE.txt
|
65
63
|
- README.md
|
66
|
-
- Rakefile
|
67
|
-
- gindex.gemspec
|
68
64
|
- lib/generators/index/index_generator.rb
|
69
|
-
- lib/generators/index/templates/index_migration.rb
|
65
|
+
- lib/generators/index/templates/index_migration.rb.tt
|
70
66
|
- lib/gindex.rb
|
71
67
|
- lib/gindex/version.rb
|
72
68
|
homepage: https://github.com/ankane/gindex
|
73
|
-
licenses:
|
69
|
+
licenses:
|
70
|
+
- MIT
|
74
71
|
metadata: {}
|
75
72
|
post_install_message:
|
76
73
|
rdoc_options: []
|
@@ -80,15 +77,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
80
77
|
requirements:
|
81
78
|
- - ">="
|
82
79
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
80
|
+
version: '2.4'
|
84
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
82
|
requirements:
|
86
83
|
- - ">="
|
87
84
|
- !ruby/object:Gem::Version
|
88
85
|
version: '0'
|
89
86
|
requirements: []
|
90
|
-
|
91
|
-
rubygems_version: 2.6.13
|
87
|
+
rubygems_version: 3.0.3
|
92
88
|
signing_key:
|
93
89
|
specification_version: 4
|
94
90
|
summary: Instant concurrent indexes for Rails
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
data/gindex.gemspec
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "gindex/version"
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "gindex"
|
8
|
-
spec.version = Gindex::VERSION
|
9
|
-
spec.authors = ["Andrew Kane"]
|
10
|
-
spec.email = ["andrew@chartkick.com"]
|
11
|
-
|
12
|
-
spec.summary = "Instant concurrent indexes for Rails"
|
13
|
-
spec.homepage = "https://github.com/ankane/gindex"
|
14
|
-
|
15
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
-
spec.bindir = "exe"
|
17
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
-
spec.require_paths = ["lib"]
|
19
|
-
|
20
|
-
spec.add_dependency "railties"
|
21
|
-
|
22
|
-
spec.add_development_dependency "bundler"
|
23
|
-
spec.add_development_dependency "rake"
|
24
|
-
end
|