schema_plus_indexes 0.3.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/prs.yml +134 -0
- data/.gitignore +1 -0
- data/.simplecov +20 -0
- data/Gemfile +4 -1
- data/README.md +14 -8
- data/Rakefile +2 -0
- data/gemfiles/Gemfile.base +1 -1
- data/gemfiles/activerecord-5.2/Gemfile.base +2 -1
- data/gemfiles/activerecord-5.2/Gemfile.mysql2 +2 -2
- data/gemfiles/activerecord-5.2/Gemfile.postgresql +2 -2
- data/gemfiles/activerecord-5.2/Gemfile.sqlite3 +3 -3
- data/gemfiles/activerecord-6.0/Gemfile.base +4 -0
- data/gemfiles/activerecord-6.0/Gemfile.mysql2 +10 -0
- data/gemfiles/activerecord-6.0/Gemfile.postgresql +10 -0
- data/gemfiles/{activerecord-4.2 → activerecord-6.0}/Gemfile.sqlite3 +3 -3
- data/lib/schema_plus/indexes/active_record/base.rb +2 -0
- data/lib/schema_plus/indexes/active_record/connection_adapters/abstract_adapter.rb +2 -0
- data/lib/schema_plus/indexes/active_record/connection_adapters/index_definition.rb +12 -37
- data/lib/schema_plus/indexes/active_record/connection_adapters/postgresql_adapter.rb +2 -0
- data/lib/schema_plus/indexes/active_record/connection_adapters/sqlite3_adapter.rb +2 -0
- data/lib/schema_plus/indexes/active_record/migration/command_recorder.rb +2 -0
- data/lib/schema_plus/indexes/middleware/dumper.rb +4 -2
- data/lib/schema_plus/indexes/middleware/migration.rb +6 -1
- data/lib/schema_plus/indexes/middleware/model.rb +2 -0
- data/lib/schema_plus/indexes/middleware/schema.rb +2 -0
- data/lib/schema_plus/indexes/remove_if_exists.rb +8 -16
- data/lib/schema_plus/indexes/version.rb +3 -1
- data/lib/schema_plus/indexes.rb +2 -1
- data/lib/schema_plus_indexes.rb +2 -0
- data/schema_dev.yml +4 -4
- data/schema_plus_indexes.gemspec +9 -9
- data/spec/command_recorder_spec.rb +2 -0
- data/spec/index_definition_spec.rb +4 -8
- data/spec/index_spec.rb +2 -0
- data/spec/migration_spec.rb +8 -9
- data/spec/named_schema_spec.rb +2 -0
- data/spec/schema_dumper_spec.rb +2 -0
- data/spec/spec_helper.rb +4 -2
- data/spec/support/enableable.rb +3 -1
- data/spec/support/matchers/have_index.rb +2 -0
- metadata +28 -78
- data/.travis.yml +0 -27
- data/gemfiles/activerecord-4.2/Gemfile.base +0 -3
- data/gemfiles/activerecord-4.2/Gemfile.mysql2 +0 -10
- data/gemfiles/activerecord-4.2/Gemfile.postgresql +0 -10
- data/gemfiles/activerecord-5.0/Gemfile.base +0 -3
- data/gemfiles/activerecord-5.0/Gemfile.mysql2 +0 -10
- data/gemfiles/activerecord-5.0/Gemfile.postgresql +0 -10
- data/gemfiles/activerecord-5.0/Gemfile.sqlite3 +0 -10
- data/gemfiles/activerecord-5.1/Gemfile.base +0 -3
- data/gemfiles/activerecord-5.1/Gemfile.mysql2 +0 -10
- data/gemfiles/activerecord-5.1/Gemfile.postgresql +0 -10
- data/gemfiles/activerecord-5.1/Gemfile.sqlite3 +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: decc66bcf6d7441ebc8722b1f6391d13240d897df6f940fc0543f6450cee507b
|
4
|
+
data.tar.gz: 429fb39c11a09a551d65fb8f8fd88b9baee2e4508c422cbfbaeddc0b630f3c56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1579a9a36aaee5fc3445f5c239bf6a245ae88bd4628b96af588ec0c83cec1e2e7dca6b8bc895ca574038ab9d895cc62b193b1fcbfc3208d98d706c0ffb3b23f9
|
7
|
+
data.tar.gz: e896e9910e9773aba80263462ad1c03c9b9517c376797ac6afa17f37d66a0e1a34c2b976eb9a81284b6e2a640cb9259e479bc848baed9b4c171998c3bc584a8b
|
@@ -0,0 +1,134 @@
|
|
1
|
+
# This file was auto-generated by the schema_dev tool, based on the data in
|
2
|
+
# ./schema_dev.yml
|
3
|
+
# Please do not edit this file; any changes will be overwritten next time
|
4
|
+
# schema_dev gets run.
|
5
|
+
---
|
6
|
+
name: CI PR Builds
|
7
|
+
'on':
|
8
|
+
push:
|
9
|
+
branches:
|
10
|
+
- master
|
11
|
+
pull_request:
|
12
|
+
concurrency:
|
13
|
+
group: ci-${{ github.ref }}
|
14
|
+
cancel-in-progress: true
|
15
|
+
jobs:
|
16
|
+
test:
|
17
|
+
runs-on: ubuntu-latest
|
18
|
+
strategy:
|
19
|
+
fail-fast: false
|
20
|
+
matrix:
|
21
|
+
ruby:
|
22
|
+
- '2.5'
|
23
|
+
- '2.7'
|
24
|
+
- '3.0'
|
25
|
+
activerecord:
|
26
|
+
- '5.2'
|
27
|
+
- '6.0'
|
28
|
+
db:
|
29
|
+
- mysql2
|
30
|
+
- sqlite3
|
31
|
+
- skip
|
32
|
+
dbversion:
|
33
|
+
- skip
|
34
|
+
exclude:
|
35
|
+
- ruby: '3.0'
|
36
|
+
activerecord: '5.2'
|
37
|
+
- db: skip
|
38
|
+
dbversion: skip
|
39
|
+
include:
|
40
|
+
- ruby: '2.5'
|
41
|
+
activerecord: '5.2'
|
42
|
+
db: postgresql
|
43
|
+
dbversion: '9.6'
|
44
|
+
- ruby: '2.5'
|
45
|
+
activerecord: '6.0'
|
46
|
+
db: postgresql
|
47
|
+
dbversion: '9.6'
|
48
|
+
- ruby: '2.7'
|
49
|
+
activerecord: '5.2'
|
50
|
+
db: postgresql
|
51
|
+
dbversion: '9.6'
|
52
|
+
- ruby: '2.7'
|
53
|
+
activerecord: '6.0'
|
54
|
+
db: postgresql
|
55
|
+
dbversion: '9.6'
|
56
|
+
- ruby: '3.0'
|
57
|
+
activerecord: '6.0'
|
58
|
+
db: postgresql
|
59
|
+
dbversion: '9.6'
|
60
|
+
env:
|
61
|
+
BUNDLE_GEMFILE: "${{ github.workspace }}/gemfiles/activerecord-${{ matrix.activerecord }}/Gemfile.${{ matrix.db }}"
|
62
|
+
MYSQL_DB_HOST: 127.0.0.1
|
63
|
+
MYSQL_DB_USER: root
|
64
|
+
MYSQL_DB_PASS: database
|
65
|
+
POSTGRESQL_DB_HOST: 127.0.0.1
|
66
|
+
POSTGRESQL_DB_USER: schema_plus_test
|
67
|
+
POSTGRESQL_DB_PASS: database
|
68
|
+
steps:
|
69
|
+
- uses: actions/checkout@v2
|
70
|
+
- name: Set up Ruby
|
71
|
+
uses: ruby/setup-ruby@v1
|
72
|
+
with:
|
73
|
+
ruby-version: "${{ matrix.ruby }}"
|
74
|
+
bundler-cache: true
|
75
|
+
- name: Run bundle update
|
76
|
+
run: bundle update
|
77
|
+
- name: Start Mysql
|
78
|
+
if: matrix.db == 'mysql2'
|
79
|
+
run: |
|
80
|
+
docker run --rm --detach \
|
81
|
+
-e MYSQL_ROOT_PASSWORD=$MYSQL_DB_PASS \
|
82
|
+
-p 3306:3306 \
|
83
|
+
--health-cmd "mysqladmin ping --host=127.0.0.1 --password=$MYSQL_DB_PASS --silent" \
|
84
|
+
--health-interval 5s \
|
85
|
+
--health-timeout 5s \
|
86
|
+
--health-retries 5 \
|
87
|
+
--name database mysql:5.6
|
88
|
+
- name: Start Postgresql
|
89
|
+
if: matrix.db == 'postgresql'
|
90
|
+
run: |
|
91
|
+
docker run --rm --detach \
|
92
|
+
-e POSTGRES_USER=$POSTGRESQL_DB_USER \
|
93
|
+
-e POSTGRES_PASSWORD=$POSTGRESQL_DB_PASS \
|
94
|
+
-p 5432:5432 \
|
95
|
+
--health-cmd "pg_isready -q" \
|
96
|
+
--health-interval 5s \
|
97
|
+
--health-timeout 5s \
|
98
|
+
--health-retries 5 \
|
99
|
+
--name database postgres:${{ matrix.dbversion }}
|
100
|
+
- name: Wait for database to start
|
101
|
+
if: "(matrix.db == 'postgresql' || matrix.db == 'mysql2')"
|
102
|
+
run: |
|
103
|
+
COUNT=0
|
104
|
+
ATTEMPTS=20
|
105
|
+
until [[ $COUNT -eq $ATTEMPTS ]]; do
|
106
|
+
[ "$(docker inspect -f {{.State.Health.Status}} database)" == "healthy" ] && break
|
107
|
+
echo $(( COUNT++ )) > /dev/null
|
108
|
+
sleep 2
|
109
|
+
done
|
110
|
+
- name: Create testing database
|
111
|
+
if: "(matrix.db == 'postgresql' || matrix.db == 'mysql2')"
|
112
|
+
run: bundle exec rake create_ci_database
|
113
|
+
- name: Run tests
|
114
|
+
run: bundle exec rake spec
|
115
|
+
- name: Shutdown database
|
116
|
+
if: always() && (matrix.db == 'postgresql' || matrix.db == 'mysql2')
|
117
|
+
run: docker stop database
|
118
|
+
- name: Coveralls Parallel
|
119
|
+
if: "${{ !env.ACT }}"
|
120
|
+
uses: coverallsapp/github-action@master
|
121
|
+
with:
|
122
|
+
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
123
|
+
flag-name: run-${{ matrix.ruby }}-${{ matrix.activerecord }}-${{ matrix.db }}-${{ matrix.dbversion }}
|
124
|
+
parallel: true
|
125
|
+
finish:
|
126
|
+
needs: test
|
127
|
+
runs-on: ubuntu-latest
|
128
|
+
steps:
|
129
|
+
- name: Coveralls Finished
|
130
|
+
if: "${{ !env.ACT }}"
|
131
|
+
uses: coverallsapp/github-action@master
|
132
|
+
with:
|
133
|
+
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
134
|
+
parallel-finished: true
|
data/.gitignore
CHANGED
data/.simplecov
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
SimpleCov.configure do
|
4
|
+
enable_coverage :branch
|
5
|
+
add_filter '/spec/'
|
6
|
+
|
7
|
+
add_group 'Binaries', '/bin/'
|
8
|
+
add_group 'Libraries', '/lib/'
|
9
|
+
|
10
|
+
if ENV['CI']
|
11
|
+
require 'simplecov-lcov'
|
12
|
+
|
13
|
+
SimpleCov::Formatter::LcovFormatter.config do |c|
|
14
|
+
c.report_with_single_file = true
|
15
|
+
c.single_report_path = 'coverage/lcov.info'
|
16
|
+
end
|
17
|
+
|
18
|
+
formatter SimpleCov::Formatter::LcovFormatter
|
19
|
+
end
|
20
|
+
end
|
data/Gemfile
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source "http://rubygems.org"
|
2
4
|
|
3
5
|
gemspec
|
4
6
|
|
5
|
-
|
7
|
+
gemfile_local = File.expand_path '../Gemfile.local', __FILE__
|
8
|
+
eval File.read(gemfile_local), binding, gemfile_local if File.exist? gemfile_local
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/schema_plus_indexes.svg)](http://badge.fury.io/rb/schema_plus_indexes)
|
2
|
-
[![Build Status](https://
|
3
|
-
[![Coverage Status](https://
|
2
|
+
[![Build Status](https://github.com/SchemaPlus/schema_plus_indexes/actions/workflows/prs.yml/badge.svg)](https://github.com/SchemaPlus/schema_plus_indexes/actions)
|
3
|
+
[![Coverage Status](https://coveralls.io/repos/github/SchemaPlus/schema_plus_indexes/badge.svg)](https://coveralls.io/github/SchemaPlus/schema_plus_indexes)
|
4
4
|
|
5
5
|
# SchemaPlus::Indexes
|
6
6
|
|
@@ -105,15 +105,22 @@ schema_plus_indexes is tested on
|
|
105
105
|
|
106
106
|
<!-- SCHEMA_DEV: MATRIX - begin -->
|
107
107
|
<!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
|
108
|
-
* ruby **2.
|
109
|
-
* ruby **2.
|
110
|
-
* ruby **2.
|
111
|
-
* ruby **2.
|
108
|
+
* ruby **2.5** with activerecord **5.2**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
109
|
+
* ruby **2.5** with activerecord **6.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
110
|
+
* ruby **2.7** with activerecord **5.2**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
111
|
+
* ruby **2.7** with activerecord **6.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
112
|
+
* ruby **3.0** with activerecord **6.0**, using **mysql2**, **sqlite3** or **postgresql:9.6**
|
112
113
|
|
113
114
|
<!-- SCHEMA_DEV: MATRIX - end -->
|
114
115
|
|
115
116
|
## Release Notes
|
116
117
|
|
118
|
+
### v1.0.0
|
119
|
+
|
120
|
+
* Drop AR < 5.2 and add 6.0 support
|
121
|
+
* Drop Ruby < 2.5 and add Ruby 3.0 support
|
122
|
+
* Remove its-it GEM
|
123
|
+
|
117
124
|
### v0.3.1
|
118
125
|
|
119
126
|
* Support AR 5.2. Thanks to [@jeremyyap](https://github.com/jeremyyap)
|
@@ -159,7 +166,7 @@ Some things to know about to help you develop and test:
|
|
159
166
|
* **schema_dev**: SchemaPlus::Indexes uses [schema_dev](https://github.com/SchemaPlus/schema_dev) to
|
160
167
|
facilitate running rspec tests on the matrix of ruby, activerecord, and database
|
161
168
|
versions that the gem supports, both locally and on
|
162
|
-
[
|
169
|
+
[github actions](https://github.com/SchemaPlus/schema_plus_indexes/actions)
|
163
170
|
|
164
171
|
To to run rspec locally on the full matrix, do:
|
165
172
|
|
@@ -171,7 +178,6 @@ Some things to know about to help you develop and test:
|
|
171
178
|
The matrix of configurations is specified in `schema_dev.yml` in
|
172
179
|
the project root.
|
173
180
|
|
174
|
-
|
175
181
|
<!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_DEV - end -->
|
176
182
|
<!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_PLUS_CORE - begin -->
|
177
183
|
<!-- These lines are auto-inserted from a schema_dev template -->
|
data/Rakefile
CHANGED
data/gemfiles/Gemfile.base
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
eval
|
1
|
+
base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
|
2
|
+
eval File.read(base_gemfile), binding, base_gemfile
|
3
3
|
|
4
4
|
platform :ruby do
|
5
5
|
gem "sqlite3"
|
@@ -7,4 +7,4 @@ end
|
|
7
7
|
|
8
8
|
platform :jruby do
|
9
9
|
gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
|
10
|
-
end
|
10
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
eval
|
1
|
+
base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
|
2
|
+
eval File.read(base_gemfile), binding, base_gemfile
|
3
3
|
|
4
4
|
platform :ruby do
|
5
5
|
gem "sqlite3"
|
@@ -7,4 +7,4 @@ end
|
|
7
7
|
|
8
8
|
platform :jruby do
|
9
9
|
gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
|
10
|
-
end
|
10
|
+
end
|
@@ -1,43 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SchemaPlus::Indexes
|
2
4
|
module ActiveRecord
|
3
5
|
module ConnectionAdapters
|
4
6
|
|
5
7
|
module IndexDefinition
|
6
|
-
|
7
|
-
attr_accessor :orders
|
8
|
+
attr_accessor :orders
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
if args.length == 3 and Hash === args.last
|
12
|
-
table_name, column_names, options = args + [{}]
|
10
|
+
def initialize(*args, **kwargs) #:nodoc:
|
11
|
+
super
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
unless orders.blank?
|
19
|
-
# fill out orders with :asc when undefined. make sure hash ordering
|
20
|
-
# follows column ordering.
|
21
|
-
if self.orders.is_a?(Hash)
|
22
|
-
self.orders = Hash[columns.map{|column| [column, orders[column] || :asc]}]
|
23
|
-
else
|
24
|
-
self.orders = Hash[columns.map{|column| [column, orders || :asc]}]
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
else
|
29
|
-
def initialize(*args) #:nodoc:
|
30
|
-
# same args as add_index(table_name, column_names, options)
|
31
|
-
if args.length == 3 and Hash === args.last
|
32
|
-
table_name, column_names, options = args + [{}]
|
33
|
-
super table_name, options[:name], options[:unique], column_names, options[:length], options[:orders], options[:where], options[:type], options[:using]
|
34
|
-
else # backwards compatibility
|
35
|
-
super
|
36
|
-
end
|
37
|
-
unless orders.blank?
|
38
|
-
# fill out orders with :asc when undefined. make sure hash ordering
|
39
|
-
# follows column ordering.
|
13
|
+
unless orders.blank?
|
14
|
+
# fill out orders with :asc when undefined. make sure hash ordering
|
15
|
+
# follows column ordering.
|
16
|
+
if self.orders.is_a?(Hash)
|
40
17
|
self.orders = Hash[columns.map{|column| [column, orders[column] || :asc]}]
|
18
|
+
else
|
19
|
+
self.orders = Hash[columns.map{|column| [column, orders || :asc]}]
|
41
20
|
end
|
42
21
|
end
|
43
22
|
end
|
@@ -48,11 +27,7 @@ module SchemaPlus::Indexes
|
|
48
27
|
return false unless self.name == other.name
|
49
28
|
return false unless Array.wrap(self.columns).collect(&:to_s).sort == Array.wrap(other.columns).collect(&:to_s).sort
|
50
29
|
return false unless !!self.unique == !!other.unique
|
51
|
-
if self.lengths
|
52
|
-
return false if (self.lengths || {}) != (other.lengths || {}) # treat nil same as empty hash
|
53
|
-
else
|
54
|
-
return false if Array.wrap(self.lengths).compact.sort != Array.wrap(other.lengths).compact.sort
|
55
|
-
end
|
30
|
+
return false if (self.lengths || {}) != (other.lengths || {}) # treat nil same as empty hash
|
56
31
|
return false unless self.where == other.where
|
57
32
|
return false unless (self.using||:btree) == (other.using||:btree)
|
58
33
|
true
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SchemaPlus::Indexes
|
2
4
|
module Middleware
|
3
5
|
module Dumper
|
@@ -11,12 +13,12 @@ module SchemaPlus::Indexes
|
|
11
13
|
env.table.columns.each do |column|
|
12
14
|
|
13
15
|
# first check for a single-column index
|
14
|
-
if (index = env.table.indexes.find
|
16
|
+
if (index = env.table.indexes.find{ |it| it.columns == [column.name] })
|
15
17
|
column.options[:index] = index_options(env, column, index)
|
16
18
|
env.table.indexes.delete(index)
|
17
19
|
|
18
20
|
# then check for the first of a multi-column index
|
19
|
-
elsif (index = env.table.indexes.find
|
21
|
+
elsif (index = env.table.indexes.find { |it| it.columns.first == column.name })
|
20
22
|
column.options[:index] = index_options(env, column, index)
|
21
23
|
env.table.indexes.delete(index)
|
22
24
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SchemaPlus::Indexes
|
2
4
|
module Middleware
|
3
5
|
module Migration
|
@@ -47,7 +49,10 @@ module SchemaPlus::Indexes
|
|
47
49
|
|
48
50
|
name = $1
|
49
51
|
existing = env.caller.indexes(env.table_name).find{|i| i.name == name}
|
50
|
-
attempted = ::ActiveRecord::ConnectionAdapters::IndexDefinition.new(
|
52
|
+
attempted = ::ActiveRecord::ConnectionAdapters::IndexDefinition.new(
|
53
|
+
env.table_name, name, env.options[:unique], env.column_names,
|
54
|
+
**env.options.except(:unique)
|
55
|
+
)
|
51
56
|
raise if attempted != existing
|
52
57
|
::ActiveRecord::Base.logger.warn "[schema_plus_indexes] Index name #{name.inspect}' on table #{env.table_name.inspect} already exists. Skipping."
|
53
58
|
end
|
@@ -1,23 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SchemaPlus::Indexes
|
2
4
|
module RemoveIfExists
|
3
5
|
# Extends rails' remove_index to include this options:
|
4
6
|
# :if_exists
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
super table_name, *args
|
12
|
-
end
|
13
|
-
else
|
14
|
-
def remove_index(table_name, *args)
|
15
|
-
options = args.extract_options!
|
16
|
-
if_exists = options.delete(:if_exists)
|
17
|
-
args << options if options.any?
|
18
|
-
return if if_exists && !index_name_exists?(table_name, options[:name] || index_name(table_name, *args), nil)
|
19
|
-
super table_name, *args
|
20
|
-
end
|
7
|
+
def remove_index(table_name, *args)
|
8
|
+
options = args.extract_options!
|
9
|
+
if_exists = options.delete(:if_exists)
|
10
|
+
args << options if options.any?
|
11
|
+
return if if_exists && !index_name_exists?(table_name, options[:name] || index_name(table_name, *args))
|
12
|
+
super table_name, *args
|
21
13
|
end
|
22
14
|
end
|
23
15
|
end
|
data/lib/schema_plus/indexes.rb
CHANGED
data/lib/schema_plus_indexes.rb
CHANGED
data/schema_dev.yml
CHANGED
data/schema_plus_indexes.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'schema_plus/indexes/version'
|
@@ -17,14 +18,13 @@ Gem::Specification.new do |gem|
|
|
17
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
19
|
gem.require_paths = ["lib"]
|
19
20
|
|
20
|
-
gem.
|
21
|
-
|
22
|
-
gem.add_dependency "
|
21
|
+
gem.required_ruby_version = ">= 2.5.0"
|
22
|
+
|
23
|
+
gem.add_dependency "activerecord", ">= 5.2", "< 6.1"
|
24
|
+
gem.add_dependency "schema_plus_core", "~> 3.0"
|
23
25
|
|
24
|
-
gem.add_development_dependency "bundler"
|
25
|
-
gem.add_development_dependency "rake", "~>
|
26
|
+
gem.add_development_dependency "bundler"
|
27
|
+
gem.add_development_dependency "rake", "~> 13.0"
|
26
28
|
gem.add_development_dependency "rspec", "~> 3.0"
|
27
|
-
gem.add_development_dependency "schema_dev", "~>
|
28
|
-
gem.add_development_dependency "simplecov"
|
29
|
-
gem.add_development_dependency "simplecov-gem-profile"
|
29
|
+
gem.add_development_dependency "schema_dev", "~> 4.1"
|
30
30
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
|
@@ -23,14 +25,8 @@ describe "Index definition" do
|
|
23
25
|
class Post < ::ActiveRecord::Base ; end
|
24
26
|
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
migration.remove_index :users, :name => 'users_login_index' if migration.index_name_exists?(:users, 'users_login_index')
|
29
|
-
end
|
30
|
-
else
|
31
|
-
after(:each) do
|
32
|
-
migration.remove_index :users, :name => 'users_login_index' if migration.index_name_exists?(:users, 'users_login_index', nil)
|
33
|
-
end
|
28
|
+
after(:each) do
|
29
|
+
migration.remove_index :users, :name => 'users_login_index' if migration.index_name_exists?(:users, 'users_login_index')
|
34
30
|
end
|
35
31
|
|
36
32
|
context "when index is multicolumn" do
|
data/spec/index_spec.rb
CHANGED
data/spec/migration_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'spec_helper'
|
3
4
|
|
4
5
|
describe ActiveRecord::Migration do
|
@@ -162,9 +163,9 @@ describe ActiveRecord::Migration do
|
|
162
163
|
|
163
164
|
protected
|
164
165
|
|
165
|
-
def add_column(column_name,
|
166
|
+
def add_column(column_name, type, **args)
|
166
167
|
table = @model.table_name
|
167
|
-
ActiveRecord::Migration.add_column(table, column_name,
|
168
|
+
ActiveRecord::Migration.add_column(table, column_name, type, **args)
|
168
169
|
@model.reset_column_information
|
169
170
|
yield if block_given?
|
170
171
|
ActiveRecord::Migration.remove_column(table, column_name)
|
@@ -172,16 +173,14 @@ describe ActiveRecord::Migration do
|
|
172
173
|
|
173
174
|
end
|
174
175
|
|
175
|
-
|
176
|
-
|
177
|
-
ActiveRecord::Migration.create_table model.table_name, opts.merge(:force => true), &block
|
176
|
+
def recreate_table(model, **opts, &block)
|
177
|
+
ActiveRecord::Migration.create_table model.table_name, **opts.merge(:force => true), &block
|
178
178
|
model.reset_column_information
|
179
179
|
end
|
180
180
|
|
181
|
-
def change_table(model, opts
|
182
|
-
ActiveRecord::Migration.change_table model.table_name, opts, &block
|
181
|
+
def change_table(model, **opts, &block)
|
182
|
+
ActiveRecord::Migration.change_table model.table_name, **opts, &block
|
183
183
|
model.reset_column_information
|
184
184
|
end
|
185
185
|
|
186
186
|
end
|
187
|
-
|
data/spec/named_schema_spec.rb
CHANGED
data/spec/schema_dumper_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/support/enableable.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Enableable
|
2
4
|
|
3
5
|
def enabled_middleware(root, env)
|
4
|
-
middleware = self.singleton_class.ancestors.find
|
6
|
+
middleware = self.singleton_class.ancestors.find { |it| it.to_s.start_with?("#{root}::Middleware") }
|
5
7
|
return nil unless middleware.enabled?(env)
|
6
8
|
middleware.disable if middleware.once?(env)
|
7
9
|
middleware
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_plus_indexes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ronen barzel
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,76 +16,62 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.2'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '6.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '5.2'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '6.1'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: schema_plus_core
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - ">="
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '0'
|
40
|
-
type: :runtime
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: its-it
|
49
35
|
requirement: !ruby/object:Gem::Requirement
|
50
36
|
requirements:
|
51
37
|
- - "~>"
|
52
38
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
39
|
+
version: '3.0'
|
54
40
|
type: :runtime
|
55
41
|
prerelease: false
|
56
42
|
version_requirements: !ruby/object:Gem::Requirement
|
57
43
|
requirements:
|
58
44
|
- - "~>"
|
59
45
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
46
|
+
version: '3.0'
|
61
47
|
- !ruby/object:Gem::Dependency
|
62
48
|
name: bundler
|
63
49
|
requirement: !ruby/object:Gem::Requirement
|
64
50
|
requirements:
|
65
|
-
- - "
|
51
|
+
- - ">="
|
66
52
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
53
|
+
version: '0'
|
68
54
|
type: :development
|
69
55
|
prerelease: false
|
70
56
|
version_requirements: !ruby/object:Gem::Requirement
|
71
57
|
requirements:
|
72
|
-
- - "
|
58
|
+
- - ">="
|
73
59
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
60
|
+
version: '0'
|
75
61
|
- !ruby/object:Gem::Dependency
|
76
62
|
name: rake
|
77
63
|
requirement: !ruby/object:Gem::Requirement
|
78
64
|
requirements:
|
79
65
|
- - "~>"
|
80
66
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
67
|
+
version: '13.0'
|
82
68
|
type: :development
|
83
69
|
prerelease: false
|
84
70
|
version_requirements: !ruby/object:Gem::Requirement
|
85
71
|
requirements:
|
86
72
|
- - "~>"
|
87
73
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
74
|
+
version: '13.0'
|
89
75
|
- !ruby/object:Gem::Dependency
|
90
76
|
name: rspec
|
91
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,72 +92,37 @@ dependencies:
|
|
106
92
|
requirements:
|
107
93
|
- - "~>"
|
108
94
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
95
|
+
version: '4.1'
|
110
96
|
type: :development
|
111
97
|
prerelease: false
|
112
98
|
version_requirements: !ruby/object:Gem::Requirement
|
113
99
|
requirements:
|
114
100
|
- - "~>"
|
115
101
|
- !ruby/object:Gem::Version
|
116
|
-
version: '
|
117
|
-
|
118
|
-
name: simplecov
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
120
|
-
requirements:
|
121
|
-
- - ">="
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: '0'
|
124
|
-
type: :development
|
125
|
-
prerelease: false
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
127
|
-
requirements:
|
128
|
-
- - ">="
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: '0'
|
131
|
-
- !ruby/object:Gem::Dependency
|
132
|
-
name: simplecov-gem-profile
|
133
|
-
requirement: !ruby/object:Gem::Requirement
|
134
|
-
requirements:
|
135
|
-
- - ">="
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: '0'
|
138
|
-
type: :development
|
139
|
-
prerelease: false
|
140
|
-
version_requirements: !ruby/object:Gem::Requirement
|
141
|
-
requirements:
|
142
|
-
- - ">="
|
143
|
-
- !ruby/object:Gem::Version
|
144
|
-
version: '0'
|
145
|
-
description:
|
102
|
+
version: '4.1'
|
103
|
+
description:
|
146
104
|
email:
|
147
105
|
- ronen@barzel.org
|
148
106
|
executables: []
|
149
107
|
extensions: []
|
150
108
|
extra_rdoc_files: []
|
151
109
|
files:
|
110
|
+
- ".github/workflows/prs.yml"
|
152
111
|
- ".gitignore"
|
153
|
-
- ".
|
112
|
+
- ".simplecov"
|
154
113
|
- Gemfile
|
155
114
|
- LICENSE.txt
|
156
115
|
- README.md
|
157
116
|
- Rakefile
|
158
117
|
- gemfiles/Gemfile.base
|
159
|
-
- gemfiles/activerecord-4.2/Gemfile.base
|
160
|
-
- gemfiles/activerecord-4.2/Gemfile.mysql2
|
161
|
-
- gemfiles/activerecord-4.2/Gemfile.postgresql
|
162
|
-
- gemfiles/activerecord-4.2/Gemfile.sqlite3
|
163
|
-
- gemfiles/activerecord-5.0/Gemfile.base
|
164
|
-
- gemfiles/activerecord-5.0/Gemfile.mysql2
|
165
|
-
- gemfiles/activerecord-5.0/Gemfile.postgresql
|
166
|
-
- gemfiles/activerecord-5.0/Gemfile.sqlite3
|
167
|
-
- gemfiles/activerecord-5.1/Gemfile.base
|
168
|
-
- gemfiles/activerecord-5.1/Gemfile.mysql2
|
169
|
-
- gemfiles/activerecord-5.1/Gemfile.postgresql
|
170
|
-
- gemfiles/activerecord-5.1/Gemfile.sqlite3
|
171
118
|
- gemfiles/activerecord-5.2/Gemfile.base
|
172
119
|
- gemfiles/activerecord-5.2/Gemfile.mysql2
|
173
120
|
- gemfiles/activerecord-5.2/Gemfile.postgresql
|
174
121
|
- gemfiles/activerecord-5.2/Gemfile.sqlite3
|
122
|
+
- gemfiles/activerecord-6.0/Gemfile.base
|
123
|
+
- gemfiles/activerecord-6.0/Gemfile.mysql2
|
124
|
+
- gemfiles/activerecord-6.0/Gemfile.postgresql
|
125
|
+
- gemfiles/activerecord-6.0/Gemfile.sqlite3
|
175
126
|
- lib/schema_plus/indexes.rb
|
176
127
|
- lib/schema_plus/indexes/active_record/base.rb
|
177
128
|
- lib/schema_plus/indexes/active_record/connection_adapters/abstract_adapter.rb
|
@@ -201,7 +152,7 @@ homepage: https://github.com/SchemaPlus/schema_plus_indexes
|
|
201
152
|
licenses:
|
202
153
|
- MIT
|
203
154
|
metadata: {}
|
204
|
-
post_install_message:
|
155
|
+
post_install_message:
|
205
156
|
rdoc_options: []
|
206
157
|
require_paths:
|
207
158
|
- lib
|
@@ -209,16 +160,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
209
160
|
requirements:
|
210
161
|
- - ">="
|
211
162
|
- !ruby/object:Gem::Version
|
212
|
-
version:
|
163
|
+
version: 2.5.0
|
213
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
214
165
|
requirements:
|
215
166
|
- - ">="
|
216
167
|
- !ruby/object:Gem::Version
|
217
168
|
version: '0'
|
218
169
|
requirements: []
|
219
|
-
|
220
|
-
|
221
|
-
signing_key:
|
170
|
+
rubygems_version: 3.0.8
|
171
|
+
signing_key:
|
222
172
|
specification_version: 4
|
223
173
|
summary: Adds shorthands and conveniences to ActiveRecord's handling of indexes
|
224
174
|
test_files:
|
data/.travis.yml
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# This file was auto-generated by the schema_dev tool, based on the data in
|
2
|
-
# ./schema_dev.yml
|
3
|
-
# Please do not edit this file; any changes will be overwritten next time
|
4
|
-
# schema_dev gets run.
|
5
|
-
---
|
6
|
-
sudo: false
|
7
|
-
rvm:
|
8
|
-
- 2.3.1
|
9
|
-
gemfile:
|
10
|
-
- gemfiles/activerecord-4.2/Gemfile.mysql2
|
11
|
-
- gemfiles/activerecord-4.2/Gemfile.postgresql
|
12
|
-
- gemfiles/activerecord-4.2/Gemfile.sqlite3
|
13
|
-
- gemfiles/activerecord-5.0/Gemfile.mysql2
|
14
|
-
- gemfiles/activerecord-5.0/Gemfile.postgresql
|
15
|
-
- gemfiles/activerecord-5.0/Gemfile.sqlite3
|
16
|
-
- gemfiles/activerecord-5.1/Gemfile.mysql2
|
17
|
-
- gemfiles/activerecord-5.1/Gemfile.postgresql
|
18
|
-
- gemfiles/activerecord-5.1/Gemfile.sqlite3
|
19
|
-
- gemfiles/activerecord-5.2/Gemfile.mysql2
|
20
|
-
- gemfiles/activerecord-5.2/Gemfile.postgresql
|
21
|
-
- gemfiles/activerecord-5.2/Gemfile.sqlite3
|
22
|
-
env: POSTGRESQL_DB_USER=postgres MYSQL_DB_USER=travis
|
23
|
-
addons:
|
24
|
-
postgresql: '9.4'
|
25
|
-
before_script: bundle exec rake create_databases
|
26
|
-
after_script: bundle exec rake drop_databases
|
27
|
-
script: bundle exec rake travis
|