schema_plus_indexes 0.2.3 → 0.2.4

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
  SHA1:
3
- metadata.gz: 5638466e8b8f9304248cd04d06746103896d8617
4
- data.tar.gz: 8603bafd7eaf1c843f85514aabd981700d377131
3
+ metadata.gz: 2d3bfc7477305f922af889109040fc663c5f02a2
4
+ data.tar.gz: aa44cff033d8bc35026cc0ac78b821dc0f5cef3b
5
5
  SHA512:
6
- metadata.gz: fa3559dc69bb4c775c2c19b7d7cc3ce09f1538cc519eabe885114e2d75efa0a906f84392a64dfce0b8514a7f3f4194029bddd6334a7bc78a25482024923faa45
7
- data.tar.gz: 5f8f66e397fed0b0aa9a5bca73d6011f70445b0a9a68e9f5e145cf8035943b01bdf7491a0972a8347b3918fa246c3aae83c8e511482ae1375ff01f8a5df528e3
6
+ metadata.gz: 1211fb491159c60fab14c1829170326944e60aa67af3fae43ccb80e17761be54c203e25b33aac2d21c6305dd32ffa5ebc09a11cfd8a1a7d46be6a3b89386cb22
7
+ data.tar.gz: 5a7b893f6e89058df0b8a2f23af5012a6fc0f126775b1c2aabfc1380d5516bb2919bb81be686303a3a2883176075c78c5d29f325486cbf367ce5c818528cfcb9
data/.travis.yml CHANGED
@@ -5,11 +5,14 @@
5
5
  ---
6
6
  sudo: false
7
7
  rvm:
8
- - 2.1.5
8
+ - 2.3.1
9
9
  gemfile:
10
10
  - gemfiles/activerecord-4.2/Gemfile.mysql2
11
11
  - gemfiles/activerecord-4.2/Gemfile.postgresql
12
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
13
16
  env: POSTGRESQL_DB_USER=postgres MYSQL_DB_USER=travis
14
17
  addons:
15
18
  postgresql: '9.4'
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/schema_plus_indexes.svg)](http://badge.fury.io/rb/schema_plus_indexes)
2
2
  [![Build Status](https://secure.travis-ci.org/SchemaPlus/schema_plus_indexes.svg)](http://travis-ci.org/SchemaPlus/schema_plus_indexes)
3
3
  [![Coverage Status](https://img.shields.io/coveralls/SchemaPlus/schema_plus_indexes.svg)](https://coveralls.io/r/SchemaPlus/schema_plus_indexes)
4
- [![Dependency Status](https://gemnasium.com/lomba/schema_plus_indexes.svg)](https://gemnasium.com/SchemaPlus/schema_plus_indexes)
5
4
 
6
5
  # SchemaPlus::Indexes
7
6
 
@@ -106,12 +105,17 @@ schema_plus_indexes is tested on
106
105
 
107
106
  <!-- SCHEMA_DEV: MATRIX - begin -->
108
107
  <!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
109
- * ruby **2.1.5** with activerecord **4.2**, using **mysql2**, **sqlite3** or **postgresql**
108
+ * ruby **2.3.1** with activerecord **4.2**, using **mysql2**, **sqlite3** or **postgresql**
109
+ * ruby **2.3.1** with activerecord **5.0**, using **mysql2**, **sqlite3** or **postgresql**
110
110
 
111
111
  <!-- SCHEMA_DEV: MATRIX - end -->
112
112
 
113
113
  ## History
114
114
 
115
+ ### v0.2.4
116
+
117
+ * Supports AR 5.0. Thanks to [@myabc][https://github.com/myabc]
118
+
115
119
 
116
120
  ### v0.2.3
117
121
 
@@ -0,0 +1,3 @@
1
+ eval File.read File.expand_path('../../Gemfile.base', __FILE__)
2
+
3
+ gem "activerecord", "~> 5.0.0"
@@ -0,0 +1,10 @@
1
+ require "pathname"
2
+ eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
+
4
+ platform :ruby do
5
+ gem "mysql2"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcmysql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ require "pathname"
2
+ eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
+
4
+ platform :ruby do
5
+ gem "pg"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcpostgresql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ require "pathname"
2
+ eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
+
4
+ platform :ruby do
5
+ gem "sqlite3"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
+ end
@@ -1,8 +1,11 @@
1
1
  require 'schema_plus/core'
2
2
  require 'its-it'
3
3
 
4
+ require_relative 'indexes/remove_if_exists'
4
5
  require_relative 'indexes/active_record/base'
5
6
  require_relative 'indexes/active_record/connection_adapters/abstract_adapter'
7
+ require_relative 'indexes/active_record/connection_adapters/postgresql_adapter'
8
+ require_relative 'indexes/active_record/connection_adapters/sqlite3_adapter'
6
9
  require_relative 'indexes/active_record/connection_adapters/index_definition'
7
10
  require_relative 'indexes/active_record/migration/command_recorder'
8
11
  require_relative 'indexes/middleware/dumper'
@@ -2,17 +2,7 @@ module SchemaPlus::Indexes
2
2
  module ActiveRecord
3
3
  module ConnectionAdapters
4
4
  module AbstractAdapter
5
-
6
- # Extends rails' remove_index to include this options:
7
- # :if_exists
8
- def remove_index(table_name, *args)
9
- options = args.extract_options!
10
- if_exists = options.delete(:if_exists)
11
- args << options if options.any?
12
- return if if_exists and not index_name_exists?(table_name, options[:name] || index_name(table_name, *args), false)
13
- super table_name, *args
14
- end
15
-
5
+ include ::SchemaPlus::Indexes::RemoveIfExists
16
6
  end
17
7
  end
18
8
  end
@@ -0,0 +1,9 @@
1
+ module SchemaPlus::Indexes
2
+ module ActiveRecord
3
+ module ConnectionAdapters
4
+ module PostgresqlAdapter
5
+ include ::SchemaPlus::Indexes::RemoveIfExists
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module SchemaPlus::Indexes
2
+ module ActiveRecord
3
+ module ConnectionAdapters
4
+ module Sqlite3Adapter
5
+ include ::SchemaPlus::Indexes::RemoveIfExists
6
+ end
7
+ end
8
+ end
9
+ end
@@ -8,7 +8,7 @@ module SchemaPlus::Indexes
8
8
  indexes = Hash[env.index_definitions.map{ |d| [d.name, d] }]
9
9
 
10
10
  env.connection.exec_query("SELECT name, sql FROM sqlite_master WHERE type = 'index'").map do |row|
11
- if (desc_columns = row['sql'].scan(/['"`]?(\w+)['"`]? DESC\b/).flatten).any?
11
+ if row['sql'] && (desc_columns = row['sql'].scan(/['"`]?(\w+)['"`]? DESC\b/).flatten).any?
12
12
  index = indexes[row['name']]
13
13
  index.orders = Hash[index.columns.map {|column| [column, desc_columns.include?(column) ? :desc : :asc]}]
14
14
  end
@@ -0,0 +1,13 @@
1
+ module SchemaPlus::Indexes
2
+ module RemoveIfExists
3
+ # Extends rails' remove_index to include this options:
4
+ # :if_exists
5
+ def remove_index(table_name, *args)
6
+ options = args.extract_options!
7
+ if_exists = options.delete(:if_exists)
8
+ args << options if options.any?
9
+ return if if_exists && !index_name_exists?(table_name, options[:name] || index_name(table_name, *args), false)
10
+ super table_name, *args
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  module SchemaPlus
2
2
  module Indexes
3
- VERSION = "0.2.3"
3
+ VERSION = "0.2.4"
4
4
  end
5
5
  end
data/schema_dev.yml CHANGED
@@ -1,7 +1,8 @@
1
1
  ruby:
2
- - 2.1.5
2
+ - 2.3.1
3
3
  activerecord:
4
4
  - 4.2
5
+ - 5.0
5
6
  db:
6
7
  - mysql2
7
8
  - sqlite3
@@ -17,8 +17,8 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.add_dependency "activerecord", "~> 4.2"
21
- gem.add_dependency "schema_plus_core", "~> 1.0"
20
+ gem.add_dependency "activerecord", ">= 4.2", "< 5.1"
21
+ gem.add_dependency "schema_plus_core"
22
22
  gem.add_dependency "its-it", "~> 1.2"
23
23
 
24
24
  gem.add_development_dependency "bundler", "~> 1.7"
@@ -37,7 +37,9 @@ describe "Command Recorder" do
37
37
  end
38
38
 
39
39
  it "does not fail when reverting" do
40
- migration = Class.new ::ActiveRecord::Migration do
40
+ migration = ::ActiveRecord::Migration
41
+ migration = migration[5.0] if migration.respond_to? :[] # without [], will be rails 4.2 migration
42
+ migration = Class.new migration do
41
43
  define_method(:change) {
42
44
  change_table("comments") do |t|
43
45
  t.integer :column
data/spec/index_spec.rb CHANGED
@@ -8,7 +8,7 @@ describe "index" do
8
8
  describe "add_index" do
9
9
 
10
10
  before(:each) do
11
- connection.tables.each do |table| connection.drop_table table, cascade: true end
11
+ each_table connection do |table| connection.drop_table table, cascade: true end
12
12
 
13
13
  define_schema(:auto_create => false) do
14
14
  create_table :users, :force => true do |t|
@@ -80,7 +80,7 @@ describe "index" do
80
80
  describe "remove_index" do
81
81
 
82
82
  before(:each) do
83
- connection.tables.each do |table| connection.drop_table table, cascade: true end
83
+ each_table connection do |table| connection.drop_table table, cascade: true end
84
84
  define_schema(:auto_create => false) do
85
85
  create_table :users, :force => true do |t|
86
86
  t.string :login
data/spec/spec_helper.rb CHANGED
@@ -24,9 +24,17 @@ RSpec.configure do |config|
24
24
  end
25
25
  end
26
26
 
27
+ # shim to handle connection.tables deprecation in favor of
28
+ # connection.data_sources
29
+ def each_table(connection)
30
+ (connection.try :data_sources || connection.tables).each do |table|
31
+ yield table
32
+ end
33
+ end
34
+
27
35
  def define_schema(config={}, &block)
28
36
  ActiveRecord::Schema.define do
29
- connection.tables.each do |table|
37
+ each_table(connection) do |table|
30
38
  drop_table table, :force => :cascade
31
39
  end
32
40
  instance_eval &block
metadata CHANGED
@@ -1,43 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_plus_indexes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ronen barzel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-27 00:00:00.000000000 Z
11
+ date: 2016-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.1'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '4.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.1'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: schema_plus_core
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - "~>"
37
+ - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: '1.0'
39
+ version: '0'
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - "~>"
44
+ - - ">="
39
45
  - !ruby/object:Gem::Version
40
- version: '1.0'
46
+ version: '0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: its-it
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -154,15 +160,22 @@ files:
154
160
  - gemfiles/activerecord-4.2/Gemfile.mysql2
155
161
  - gemfiles/activerecord-4.2/Gemfile.postgresql
156
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
157
167
  - lib/schema_plus/indexes.rb
158
168
  - lib/schema_plus/indexes/active_record/base.rb
159
169
  - lib/schema_plus/indexes/active_record/connection_adapters/abstract_adapter.rb
160
170
  - lib/schema_plus/indexes/active_record/connection_adapters/index_definition.rb
171
+ - lib/schema_plus/indexes/active_record/connection_adapters/postgresql_adapter.rb
172
+ - lib/schema_plus/indexes/active_record/connection_adapters/sqlite3_adapter.rb
161
173
  - lib/schema_plus/indexes/active_record/migration/command_recorder.rb
162
174
  - lib/schema_plus/indexes/middleware/dumper.rb
163
175
  - lib/schema_plus/indexes/middleware/migration.rb
164
176
  - lib/schema_plus/indexes/middleware/model.rb
165
177
  - lib/schema_plus/indexes/middleware/schema.rb
178
+ - lib/schema_plus/indexes/remove_if_exists.rb
166
179
  - lib/schema_plus/indexes/version.rb
167
180
  - lib/schema_plus_indexes.rb
168
181
  - schema_dev.yml
@@ -196,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
209
  version: '0'
197
210
  requirements: []
198
211
  rubyforge_project:
199
- rubygems_version: 2.2.2
212
+ rubygems_version: 2.5.1
200
213
  signing_key:
201
214
  specification_version: 4
202
215
  summary: Adds shorthands and conveniences to ActiveRecord's handling of indexes