gindex 0.1.0 → 0.3.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 +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -12
- data/lib/generators/index/index_generator.rb +30 -0
- data/lib/generators/index/templates/index_migration.rb.tt +7 -0
- data/lib/gindex/version.rb +1 -1
- metadata +19 -51
- data/.gitignore +0 -9
- data/Gemfile +0 -4
- data/Rakefile +0 -1
- data/gindex.gemspec +0 -24
- data/lib/generators/index_generator.rb +0 -26
- data/lib/generators/templates/index_migration.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bdb3b0d5be3d4f72b4e2cd9c0e3469bd96980b4e1909f14bc755442d68131920
|
4
|
+
data.tar.gz: 551566c8043baae73b1de307a09b67759b10aac746776132c693619c450c1cb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bed474abae726b41b17f0d8b773ab941a3ef43adf1223fc2d2ea39c0a66d64759746cffd615cbfd942cf99d95a909a2a2cd08f47cfa1b887653ab000633c7d58
|
7
|
+
data.tar.gz: 27ce4c182bdaa83d575267048beb782481e048cdb0e42516deaa804d891015171e5f5ac77d3e1afe464e8806801dc5f0d3964616744f700612e6c83d07144499
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
## 0.3.0 (2022-01-10)
|
2
|
+
|
3
|
+
- Dropped support for Ruby < 2.6 and Rails < 5.2
|
4
|
+
|
5
|
+
## 0.2.0 (2019-12-20)
|
6
|
+
|
7
|
+
- Added support for custom migrations path
|
8
|
+
- Improved migration for single column
|
9
|
+
- Dropped support for Rails 4.2
|
10
|
+
|
11
|
+
## 0.1.2 (2018-03-22)
|
12
|
+
|
13
|
+
- Added support for Rails 5
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015-2022 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
@@ -1,35 +1,47 @@
|
|
1
|
-
#
|
1
|
+
# g index
|
2
2
|
|
3
|
-
:
|
3
|
+
:speedboat: Instant **concurrent** index migrations for Rails
|
4
4
|
|
5
|
-
|
6
|
-
rails g index users email
|
7
|
-
```
|
5
|
+
## Installation
|
8
6
|
|
9
|
-
|
7
|
+
Add this line to your application’s Gemfile:
|
10
8
|
|
11
9
|
```ruby
|
12
|
-
|
10
|
+
gem "gindex", group: :development
|
13
11
|
```
|
14
12
|
|
15
|
-
##
|
13
|
+
## How It Works
|
16
14
|
|
17
|
-
|
15
|
+
```sh
|
16
|
+
rails g index users email
|
17
|
+
```
|
18
|
+
|
19
|
+
generates:
|
18
20
|
|
19
21
|
```ruby
|
20
|
-
|
22
|
+
class AddIndexOnEmailToUsers < ActiveRecord::Migration[6.1]
|
23
|
+
disable_ddl_transaction!
|
24
|
+
|
25
|
+
def change
|
26
|
+
add_index :users, :email, algorithm: :concurrently
|
27
|
+
end
|
28
|
+
end
|
21
29
|
```
|
22
30
|
|
23
|
-
|
31
|
+
Also works with multi-column indexes
|
24
32
|
|
25
33
|
```sh
|
26
|
-
|
34
|
+
rails g index deliveries store_id delivered_at
|
27
35
|
```
|
28
36
|
|
29
37
|
## TODO
|
30
38
|
|
31
39
|
- add `:name` option to long index names
|
32
40
|
|
41
|
+
## History
|
42
|
+
|
43
|
+
View the [changelog](https://github.com/ankane/gindex/blob/master/CHANGELOG.md)
|
44
|
+
|
33
45
|
## Contributing
|
34
46
|
|
35
47
|
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
@@ -38,3 +50,11 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
|
|
38
50
|
- Fix bugs and [submit pull requests](https://github.com/ankane/gindex/pulls)
|
39
51
|
- Write, clarify, or fix documentation
|
40
52
|
- Suggest or add new features
|
53
|
+
|
54
|
+
To get started with development:
|
55
|
+
|
56
|
+
```sh
|
57
|
+
git clone https://github.com/ankane/gindex.git
|
58
|
+
cd gindex
|
59
|
+
bundle install
|
60
|
+
```
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "rails/generators/active_record"
|
2
|
+
|
3
|
+
class IndexGenerator < Rails::Generators::Base
|
4
|
+
include ActiveRecord::Generators::Migration
|
5
|
+
source_root File.join(__dir__, "templates")
|
6
|
+
|
7
|
+
argument :table, type: :string
|
8
|
+
argument :columns, type: :array
|
9
|
+
|
10
|
+
def copy_migration
|
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"
|
13
|
+
end
|
14
|
+
|
15
|
+
def migration_version
|
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
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/gindex/version.rb
CHANGED
metadata
CHANGED
@@ -1,77 +1,47 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gindex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: railties
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.2'
|
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: '
|
27
|
-
|
28
|
-
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.9'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.9'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '10.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '10.0'
|
55
|
-
description:
|
56
|
-
email:
|
57
|
-
- andrew@chartkick.com
|
26
|
+
version: '5.2'
|
27
|
+
description:
|
28
|
+
email: andrew@ankane.org
|
58
29
|
executables: []
|
59
30
|
extensions: []
|
60
31
|
extra_rdoc_files: []
|
61
32
|
files:
|
62
|
-
-
|
63
|
-
-
|
33
|
+
- CHANGELOG.md
|
34
|
+
- LICENSE.txt
|
64
35
|
- README.md
|
65
|
-
-
|
66
|
-
-
|
67
|
-
- lib/generators/index_generator.rb
|
68
|
-
- lib/generators/templates/index_migration.rb
|
36
|
+
- lib/generators/index/index_generator.rb
|
37
|
+
- lib/generators/index/templates/index_migration.rb.tt
|
69
38
|
- lib/gindex.rb
|
70
39
|
- lib/gindex/version.rb
|
71
40
|
homepage: https://github.com/ankane/gindex
|
72
|
-
licenses:
|
41
|
+
licenses:
|
42
|
+
- MIT
|
73
43
|
metadata: {}
|
74
|
-
post_install_message:
|
44
|
+
post_install_message:
|
75
45
|
rdoc_options: []
|
76
46
|
require_paths:
|
77
47
|
- lib
|
@@ -79,17 +49,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
49
|
requirements:
|
80
50
|
- - ">="
|
81
51
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
52
|
+
version: '2.6'
|
83
53
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
54
|
requirements:
|
85
55
|
- - ">="
|
86
56
|
- !ruby/object:Gem::Version
|
87
57
|
version: '0'
|
88
58
|
requirements: []
|
89
|
-
|
90
|
-
|
91
|
-
signing_key:
|
59
|
+
rubygems_version: 3.3.3
|
60
|
+
signing_key:
|
92
61
|
specification_version: 4
|
93
62
|
summary: Instant concurrent indexes for Rails
|
94
63
|
test_files: []
|
95
|
-
has_rdoc:
|
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 "rails"
|
21
|
-
|
22
|
-
spec.add_development_dependency "bundler", "~> 1.9"
|
23
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# taken from https://github.com/collectiveidea/audited/blob/master/lib/generators/audited/install_generator.rb
|
2
|
-
require "rails/generators"
|
3
|
-
require "rails/generators/migration"
|
4
|
-
require "active_record"
|
5
|
-
require "rails/generators/active_record"
|
6
|
-
|
7
|
-
class IndexGenerator < Rails::Generators::Base
|
8
|
-
include Rails::Generators::Migration
|
9
|
-
source_root File.expand_path("../templates", __FILE__)
|
10
|
-
argument :table, type: :string
|
11
|
-
argument :columns, type: :array
|
12
|
-
|
13
|
-
# Implement the required interface for Rails::Generators::Migration.
|
14
|
-
def self.next_migration_number(dirname) #:nodoc:
|
15
|
-
next_migration_number = current_migration_number(dirname) + 1
|
16
|
-
if ::ActiveRecord::Base.timestamped_migrations
|
17
|
-
[Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
|
18
|
-
else
|
19
|
-
"%.3d" % next_migration_number
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def copy_migration
|
24
|
-
migration_template "index_migration.rb", "db/migrate/add_index_on_#{columns.join('_and_')}_to_#{table}.rb"
|
25
|
-
end
|
26
|
-
end
|