acts-as-taggable-on 4.0.0.pre → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -1
  3. data/.travis.yml +28 -15
  4. data/Appraisals +12 -10
  5. data/CHANGELOG.md +200 -71
  6. data/CONTRIBUTING.md +13 -0
  7. data/Gemfile +1 -1
  8. data/README.md +68 -28
  9. data/acts-as-taggable-on.gemspec +2 -6
  10. data/db/migrate/1_acts_as_taggable_on_migration.rb +14 -8
  11. data/db/migrate/2_add_missing_unique_indices.rb +14 -9
  12. data/db/migrate/3_add_taggings_counter_cache_to_tags.rb +9 -4
  13. data/db/migrate/4_add_missing_taggable_index.rb +8 -3
  14. data/db/migrate/5_change_collation_for_tag_names.rb +7 -2
  15. data/db/migrate/6_add_missing_indexes_on_taggings.rb +22 -0
  16. data/gemfiles/activerecord_5.0.gemfile +11 -5
  17. data/gemfiles/activerecord_5.1.gemfile +21 -0
  18. data/gemfiles/activerecord_5.2.gemfile +21 -0
  19. data/gemfiles/activerecord_6.0.gemfile +21 -0
  20. data/gemfiles/activerecord_6.1.gemfile +23 -0
  21. data/lib/acts-as-taggable-on.rb +6 -2
  22. data/lib/acts_as_taggable_on/tag.rb +17 -23
  23. data/lib/acts_as_taggable_on/tag_list.rb +1 -0
  24. data/lib/acts_as_taggable_on/taggable.rb +0 -1
  25. data/lib/acts_as_taggable_on/taggable/cache.rb +38 -34
  26. data/lib/acts_as_taggable_on/taggable/collection.rb +9 -7
  27. data/lib/acts_as_taggable_on/taggable/core.rb +41 -181
  28. data/lib/acts_as_taggable_on/taggable/ownership.rb +16 -5
  29. data/lib/acts_as_taggable_on/taggable/related.rb +1 -1
  30. data/lib/acts_as_taggable_on/taggable/tag_list_type.rb +4 -0
  31. data/lib/acts_as_taggable_on/taggable/tagged_with_query.rb +16 -0
  32. data/lib/acts_as_taggable_on/taggable/tagged_with_query/all_tags_query.rb +111 -0
  33. data/lib/acts_as_taggable_on/taggable/tagged_with_query/any_tags_query.rb +70 -0
  34. data/lib/acts_as_taggable_on/taggable/tagged_with_query/exclude_tags_query.rb +82 -0
  35. data/lib/acts_as_taggable_on/taggable/tagged_with_query/query_base.rb +61 -0
  36. data/lib/acts_as_taggable_on/tagger.rb +3 -3
  37. data/lib/acts_as_taggable_on/tagging.rb +6 -3
  38. data/lib/acts_as_taggable_on/utils.rb +4 -4
  39. data/lib/acts_as_taggable_on/version.rb +1 -2
  40. data/spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb +4 -12
  41. data/spec/acts_as_taggable_on/caching_spec.rb +34 -10
  42. data/spec/acts_as_taggable_on/{taggable/dirty_spec.rb → dirty_spec.rb} +28 -13
  43. data/spec/acts_as_taggable_on/single_table_inheritance_spec.rb +28 -8
  44. data/spec/acts_as_taggable_on/taggable_spec.rb +16 -13
  45. data/spec/acts_as_taggable_on/tagger_spec.rb +2 -2
  46. data/spec/internal/app/models/altered_inheriting_taggable_model.rb +2 -0
  47. data/spec/internal/app/models/cached_model_with_array.rb +6 -0
  48. data/spec/internal/app/models/columns_override_model.rb +5 -0
  49. data/spec/internal/app/models/company.rb +1 -1
  50. data/spec/internal/app/models/inheriting_taggable_model.rb +2 -0
  51. data/spec/internal/app/models/market.rb +1 -1
  52. data/spec/internal/app/models/non_standard_id_taggable_model.rb +1 -1
  53. data/spec/internal/app/models/student.rb +2 -0
  54. data/spec/internal/app/models/taggable_model.rb +1 -0
  55. data/spec/internal/app/models/user.rb +1 -1
  56. data/spec/internal/db/schema.rb +14 -5
  57. data/spec/spec_helper.rb +0 -1
  58. data/spec/support/database.rb +4 -4
  59. metadata +30 -61
  60. data/db/migrate/6_add_missing_indexes.rb +0 -12
  61. data/gemfiles/activerecord_4.0.gemfile +0 -16
  62. data/gemfiles/activerecord_4.1.gemfile +0 -16
  63. data/gemfiles/activerecord_4.2.gemfile +0 -15
  64. data/lib/acts_as_taggable_on/taggable/dirty.rb +0 -36
  65. data/spec/internal/app/models/models.rb +0 -90
@@ -1,3 +1,16 @@
1
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
2
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3
+ **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
4
+
5
+ - [How to contribute:](#how-to-contribute)
6
+ - [Bug reports / Issues](#bug-reports--issues)
7
+ - [Code](#code)
8
+ - [Commit Messages](#commit-messages)
9
+ - [About Pull Requests (PR's)](#about-pull-requests-prs)
10
+ - [Documentation](#documentation)
11
+
12
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
13
+
1
14
  # How to contribute:
2
15
 
3
16
  ## Bug reports / Issues
data/Gemfile CHANGED
@@ -7,5 +7,5 @@ group :local_development do
7
7
  gem 'guard-rspec'
8
8
  gem 'appraisal'
9
9
  gem 'rake'
10
- gem 'byebug' , platforms: [:mri_21, :mri_22, :mri_23]
10
+ gem 'byebug', platforms: [:mri]
11
11
  end
data/README.md CHANGED
@@ -1,10 +1,41 @@
1
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
2
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3
+ **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
4
+
5
+ - [ActsAsTaggableOn](#actsastaggableon)
6
+ - [Installation](#installation)
7
+ - [Post Installation](#post-installation)
8
+ - [For MySql users](#for-mysql-users)
9
+ - [Usage](#usage)
10
+ - [Finding most or least used tags](#finding-most-or-least-used-tags)
11
+ - [Finding Tagged Objects](#finding-tagged-objects)
12
+ - [Relationships](#relationships)
13
+ - [Dynamic Tag Contexts](#dynamic-tag-contexts)
14
+ - [Tag Parsers](#tag-parsers)
15
+ - [Tag Ownership](#tag-ownership)
16
+ - [Working with Owned Tags](#working-with-owned-tags)
17
+ - [Adding owned tags](#adding-owned-tags)
18
+ - [Removing owned tags](#removing-owned-tags)
19
+ - [Dirty objects](#dirty-objects)
20
+ - [Tag cloud calculations](#tag-cloud-calculations)
21
+ - [Configuration](#configuration)
22
+ - [Upgrading](#upgrading)
23
+ - [Contributors](#contributors)
24
+ - [Compatibility](#compatibility)
25
+ - [TODO](#todo)
26
+ - [Testing](#testing)
27
+ - [License](#license)
28
+
29
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
30
+
1
31
  # ActsAsTaggableOn
2
32
 
3
33
  [![Join the chat at https://gitter.im/mbleigh/acts-as-taggable-on](https://badges.gitter.im/mbleigh/acts-as-taggable-on.svg)](https://gitter.im/mbleigh/acts-as-taggable-on?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
34
  [![Gem Version](https://badge.fury.io/rb/acts-as-taggable-on.svg)](http://badge.fury.io/rb/acts-as-taggable-on)
5
- [![Build Status](https://secure.travis-ci.org/mbleigh/acts-as-taggable-on.png)](http://travis-ci.org/mbleigh/acts-as-taggable-on)
6
- [![Code Climate](https://codeclimate.com/github/mbleigh/acts-as-taggable-on.png)](https://codeclimate.com/github/mbleigh/acts-as-taggable-on)
7
- [![Inline docs](http://inch-ci.org/github/mbleigh/acts-as-taggable-on.png)](http://inch-ci.org/github/mbleigh/acts-as-taggable-on)
35
+ [![Build Status](https://secure.travis-ci.org/mbleigh/acts-as-taggable-on.svg)](http://travis-ci.org/mbleigh/acts-as-taggable-on)
36
+ [![Code Climate](https://codeclimate.com/github/mbleigh/acts-as-taggable-on.svg)](https://codeclimate.com/github/mbleigh/acts-as-taggable-on)
37
+ [![Inline docs](http://inch-ci.org/github/mbleigh/acts-as-taggable-on.svg)](http://inch-ci.org/github/mbleigh/acts-as-taggable-on)
38
+ [![Security](https://hakiri.io/github/mbleigh/acts-as-taggable-on/master.svg)](https://hakiri.io/github/mbleigh/acts-as-taggable-on/master)
8
39
 
9
40
  This plugin was originally based on Acts as Taggable on Steroids by Jonathan Viney.
10
41
  It has evolved substantially since that point, but all credit goes to him for the
@@ -19,22 +50,14 @@ Enter Acts as Taggable On. Rather than tying functionality to a specific keyword
19
50
  tag "contexts" that can be used locally or in combination in the same way steroids
20
51
  was used.
21
52
 
22
- ## Compatibility
23
-
24
- Versions 2.x are compatible with Ruby 1.8.7+ and Rails 3.
25
-
26
- Versions 2.4.1 and up are compatible with Rails 4 too (thanks to arabonradar and cwoodcox).
27
53
 
28
- Versions >= 3.x are compatible with Ruby 1.9.3+ and Rails 3 and 4.
29
-
30
- For an up-to-date roadmap, see https://github.com/mbleigh/acts-as-taggable-on/milestones
31
54
 
32
55
  ## Installation
33
56
 
34
57
  To use it, add it to your Gemfile:
35
58
 
36
59
  ```ruby
37
- gem 'acts-as-taggable-on', '~> 3.4'
60
+ gem 'acts-as-taggable-on', '~> 6.0'
38
61
  ```
39
62
 
40
63
  and bundle:
@@ -50,8 +73,6 @@ Install migrations
50
73
  ```shell
51
74
  # For the latest versions :
52
75
  rake acts_as_taggable_on_engine:install:migrations
53
- # For versions 2.4.1 and earlier :
54
- rails generate acts_as_taggable_on:migration
55
76
  ```
56
77
 
57
78
  Review the generated migrations then migrate :
@@ -75,9 +96,6 @@ rake acts_as_taggable_on_engine:tag_names:collate_bin
75
96
  See the Configuration section for more details, and a general note valid for older
76
97
  version of the gem.
77
98
 
78
- #### Upgrading
79
-
80
- see [UPGRADING](UPGRADING.md)
81
99
 
82
100
  ## Usage
83
101
 
@@ -85,8 +103,8 @@ Setup
85
103
 
86
104
  ```ruby
87
105
  class User < ActiveRecord::Base
88
- acts_as_taggable # Alias for acts_as_taggable_on :tags
89
- acts_as_taggable_on :skills, :interests
106
+ acts_as_taggable_on :tags
107
+ acts_as_taggable_on :skills, :interests #You can also configure multiple tag types per model
90
108
  end
91
109
 
92
110
  class UsersController < ApplicationController
@@ -103,6 +121,7 @@ Add and remove a single tag
103
121
  ```ruby
104
122
  @user.tag_list.add("awesome") # add a single tag. alias for <<
105
123
  @user.tag_list.remove("awesome") # remove a single tag
124
+ @user.save # save to persist tag_list
106
125
  ```
107
126
 
108
127
  Add and remove multiple tags in an array
@@ -110,6 +129,7 @@ Add and remove multiple tags in an array
110
129
  ```ruby
111
130
  @user.tag_list.add("awesome", "slick")
112
131
  @user.tag_list.remove("awesome", "slick")
132
+ @user.save
113
133
  ```
114
134
 
115
135
  You can also add and remove tags in format of String. This would
@@ -220,12 +240,13 @@ User.tagged_with("awesome").by_join_date
220
240
  User.tagged_with("awesome").by_join_date.paginate(:page => params[:page], :per_page => 20)
221
241
 
222
242
  # Find users that matches all given tags:
243
+ # NOTE: This only matches users that have the exact set of specified tags. If a user has additional tags, they are not returned.
223
244
  User.tagged_with(["awesome", "cool"], :match_all => true)
224
245
 
225
246
  # Find users with any of the specified tags:
226
247
  User.tagged_with(["awesome", "cool"], :any => true)
227
248
 
228
- # Find users that has not been tagged with awesome or cool:
249
+ # Find users that have not been tagged with awesome or cool:
229
250
  User.tagged_with(["awesome", "cool"], :exclude => true)
230
251
 
231
252
  # Find users with any of the tags based on context:
@@ -345,12 +366,12 @@ Note that **owned tags** are added all at once, in the form of ***comma seperate
345
366
  Also, when you try to add **owned tags** again, it simply overwrites the previous set of **owned tags**.
346
367
  So to append tags in previously existing **owned tags** list, go as follows:
347
368
  ```ruby
348
- def add_owned_tag
369
+ def add_owned_tag
349
370
  @some_item = Item.find(params[:id])
350
- owned_tag_list = @some_item.all_tag_list - @some_item.tag_list
371
+ owned_tag_list = @some_item.all_tags_list - @some_item.tag_list
351
372
  owned_tag_list += [(params[:tag])]
352
373
  @tag_owner.tag(@some_item, :with => stringify(owned_tag_list), :on => :tags)
353
- @some_item.save
374
+ @some_item.save
354
375
  end
355
376
 
356
377
  def stringify(tag_list)
@@ -360,12 +381,12 @@ end
360
381
  ##### Removing owned tags
361
382
  Similarly as above, removing will be as follows:
362
383
  ```ruby
363
- def remove_owned_tag
384
+ def remove_owned_tag
364
385
  @some_item = Item.find(params[:id])
365
- owned_tag_list = @some_item.all_tag_list - @some_item.tag_list
386
+ owned_tag_list = @some_item.all_tags_list - @some_item.tag_list
366
387
  owned_tag_list -= [(params[:tag])]
367
388
  @tag_owner.tag(@some_item, :with => stringify(owned_tag_list), :on => :tags)
368
- @some_item.save
389
+ @some_item.save
369
390
  end
370
391
  ```
371
392
 
@@ -467,6 +488,13 @@ If you would like to have an exact match covering special characters with MySql:
467
488
  ActsAsTaggableOn.force_binary_collation = true
468
489
  ```
469
490
 
491
+ If you would like to specify table names:
492
+
493
+ ```ruby
494
+ ActsAsTaggableOn.tags_table = 'aato_tags'
495
+ ActsAsTaggableOn.taggings_table = 'aato_taggings'
496
+ ```
497
+
470
498
  If you want to change the default delimiter (it defaults to ','). You can also pass in an array of delimiters such as ([',', '|']):
471
499
 
472
500
  ```ruby
@@ -484,13 +512,25 @@ USE my_wonderful_app_db;
484
512
  ALTER TABLE tags MODIFY name VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin;
485
513
  ```
486
514
 
515
+ #### Upgrading
516
+
517
+ see [UPGRADING](UPGRADING.md)
518
+
487
519
  ## Contributors
488
520
 
489
521
  We have a long list of valued contributors. [Check them all](https://github.com/mbleigh/acts-as-taggable-on/contributors)
490
522
 
491
- ## Maintainer
523
+ ## Compatibility
492
524
 
493
- * [Joost Baaij](https://github.com/tilsammans)
525
+ Versions 2.x are compatible with Ruby 1.8.7+ and Rails 3.
526
+
527
+ Versions 2.4.1 and up are compatible with Rails 4 too (thanks to arabonradar and cwoodcox).
528
+
529
+ Versions >= 3.x are compatible with Ruby 1.9.3+ and Rails 3 and 4.
530
+
531
+ Versions >= 4.x are compatible with Ruby 2.0.0+ and Rails 4 and 5.
532
+
533
+ For an up-to-date roadmap, see https://github.com/mbleigh/acts-as-taggable-on/milestones
494
534
 
495
535
  ## TODO
496
536
 
@@ -16,17 +16,13 @@ Gem::Specification.new do |gem|
16
16
  gem.files = `git ls-files`.split($/)
17
17
  gem.test_files = gem.files.grep(%r{^spec/})
18
18
  gem.require_paths = ['lib']
19
- gem.required_ruby_version = '>= 2.0.0'
19
+ gem.required_ruby_version = '>= 2.3.7'
20
20
 
21
21
  if File.exist?('UPGRADING.md')
22
22
  gem.post_install_message = File.read('UPGRADING.md')
23
23
  end
24
24
 
25
- gem.add_runtime_dependency 'activerecord', ['>= 4.0']
26
-
27
- gem.add_development_dependency 'sqlite3'
28
- gem.add_development_dependency 'mysql2', '~> 0.3'
29
- gem.add_development_dependency 'pg'
25
+ gem.add_runtime_dependency 'activerecord', '>= 5.0', '< 6.2'
30
26
 
31
27
  gem.add_development_dependency 'rspec-rails'
32
28
  gem.add_development_dependency 'rspec-its'
@@ -1,11 +1,17 @@
1
- class ActsAsTaggableOnMigration < ActiveRecord::Migration
1
+ if ActiveRecord.gem_version >= Gem::Version.new('5.0')
2
+ class ActsAsTaggableOnMigration < ActiveRecord::Migration[4.2]; end
3
+ else
4
+ class ActsAsTaggableOnMigration < ActiveRecord::Migration; end
5
+ end
6
+ ActsAsTaggableOnMigration.class_eval do
2
7
  def self.up
3
- create_table :tags do |t|
8
+ create_table ActsAsTaggableOn.tags_table do |t|
4
9
  t.string :name
10
+ t.timestamps
5
11
  end
6
12
 
7
- create_table :taggings do |t|
8
- t.references :tag
13
+ create_table ActsAsTaggableOn.taggings_table do |t|
14
+ t.references :tag, foreign_key: { to_table: ActsAsTaggableOn.tags_table }
9
15
 
10
16
  # You should make sure that the column created is
11
17
  # long enough to store the required class names.
@@ -19,12 +25,12 @@ class ActsAsTaggableOnMigration < ActiveRecord::Migration
19
25
  t.datetime :created_at
20
26
  end
21
27
 
22
- add_index :taggings, :tag_id
23
- add_index :taggings, [:taggable_id, :taggable_type, :context]
28
+ add_index ActsAsTaggableOn.taggings_table, :tag_id
29
+ add_index ActsAsTaggableOn.taggings_table, [:taggable_id, :taggable_type, :context], name: 'taggings_taggable_context_idx'
24
30
  end
25
31
 
26
32
  def self.down
27
- drop_table :taggings
28
- drop_table :tags
33
+ drop_table ActsAsTaggableOn.taggings_table
34
+ drop_table ActsAsTaggableOn.tags_table
29
35
  end
30
36
  end
@@ -1,20 +1,25 @@
1
- class AddMissingUniqueIndices < ActiveRecord::Migration
1
+ if ActiveRecord.gem_version >= Gem::Version.new('5.0')
2
+ class AddMissingUniqueIndices < ActiveRecord::Migration[4.2]; end
3
+ else
4
+ class AddMissingUniqueIndices < ActiveRecord::Migration; end
5
+ end
6
+ AddMissingUniqueIndices.class_eval do
2
7
  def self.up
3
- add_index :tags, :name, unique: true
8
+ add_index ActsAsTaggableOn.tags_table, :name, unique: true
4
9
 
5
- remove_index :taggings, :tag_id if index_exists?(:taggings, :tag_id)
6
- remove_index :taggings, [:taggable_id, :taggable_type, :context]
7
- add_index :taggings,
10
+ remove_index ActsAsTaggableOn.taggings_table, :tag_id if index_exists?(ActsAsTaggableOn.taggings_table, :tag_id)
11
+ remove_index ActsAsTaggableOn.taggings_table, name: 'taggings_taggable_context_idx'
12
+ add_index ActsAsTaggableOn.taggings_table,
8
13
  [:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
9
14
  unique: true, name: 'taggings_idx'
10
15
  end
11
16
 
12
17
  def self.down
13
- remove_index :tags, :name
18
+ remove_index ActsAsTaggableOn.tags_table, :name
14
19
 
15
- remove_index :taggings, name: 'taggings_idx'
20
+ remove_index ActsAsTaggableOn.taggings_table, name: 'taggings_idx'
16
21
 
17
- add_index :taggings, :tag_id unless index_exists?(:taggings, :tag_id)
18
- add_index :taggings, [:taggable_id, :taggable_type, :context]
22
+ add_index ActsAsTaggableOn.taggings_table, :tag_id unless index_exists?(ActsAsTaggableOn.taggings_table, :tag_id)
23
+ add_index ActsAsTaggableOn.taggings_table, [:taggable_id, :taggable_type, :context], name: 'taggings_taggable_context_idx'
19
24
  end
20
25
  end
@@ -1,14 +1,19 @@
1
- class AddTaggingsCounterCacheToTags < ActiveRecord::Migration
1
+ if ActiveRecord.gem_version >= Gem::Version.new('5.0')
2
+ class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[4.2]; end
3
+ else
4
+ class AddTaggingsCounterCacheToTags < ActiveRecord::Migration; end
5
+ end
6
+ AddTaggingsCounterCacheToTags.class_eval do
2
7
  def self.up
3
- add_column :tags, :taggings_count, :integer, default: 0
8
+ add_column ActsAsTaggableOn.tags_table, :taggings_count, :integer, default: 0
4
9
 
5
10
  ActsAsTaggableOn::Tag.reset_column_information
6
11
  ActsAsTaggableOn::Tag.find_each do |tag|
7
- ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings)
12
+ ActsAsTaggableOn::Tag.reset_counters(tag.id, ActsAsTaggableOn.taggings_table)
8
13
  end
9
14
  end
10
15
 
11
16
  def self.down
12
- remove_column :tags, :taggings_count
17
+ remove_column ActsAsTaggableOn.tags_table, :taggings_count
13
18
  end
14
19
  end
@@ -1,9 +1,14 @@
1
- class AddMissingTaggableIndex < ActiveRecord::Migration
1
+ if ActiveRecord.gem_version >= Gem::Version.new('5.0')
2
+ class AddMissingTaggableIndex < ActiveRecord::Migration[4.2]; end
3
+ else
4
+ class AddMissingTaggableIndex < ActiveRecord::Migration; end
5
+ end
6
+ AddMissingTaggableIndex.class_eval do
2
7
  def self.up
3
- add_index :taggings, [:taggable_id, :taggable_type, :context]
8
+ add_index ActsAsTaggableOn.taggings_table, [:taggable_id, :taggable_type, :context], name: 'taggings_taggable_context_idx'
4
9
  end
5
10
 
6
11
  def self.down
7
- remove_index :taggings, [:taggable_id, :taggable_type, :context]
12
+ remove_index ActsAsTaggableOn.taggings_table, name: 'taggings_taggable_context_idx'
8
13
  end
9
14
  end
@@ -1,9 +1,14 @@
1
1
  # This migration is added to circumvent issue #623 and have special characters
2
2
  # work properly
3
- class ChangeCollationForTagNames < ActiveRecord::Migration
3
+ if ActiveRecord.gem_version >= Gem::Version.new('5.0')
4
+ class ChangeCollationForTagNames < ActiveRecord::Migration[4.2]; end
5
+ else
6
+ class ChangeCollationForTagNames < ActiveRecord::Migration; end
7
+ end
8
+ ChangeCollationForTagNames.class_eval do
4
9
  def up
5
10
  if ActsAsTaggableOn::Utils.using_mysql?
6
- execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;")
11
+ execute("ALTER TABLE #{ActsAsTaggableOn.tags_table} MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;")
7
12
  end
8
13
  end
9
14
  end
@@ -0,0 +1,22 @@
1
+ if ActiveRecord.gem_version >= Gem::Version.new('5.0')
2
+ class AddMissingIndexesOnTaggings < ActiveRecord::Migration[4.2]; end
3
+ else
4
+ class AddMissingIndexesOnTaggings < ActiveRecord::Migration; end
5
+ end
6
+ AddMissingIndexesOnTaggings.class_eval do
7
+ def change
8
+ add_index ActsAsTaggableOn.taggings_table, :tag_id unless index_exists? ActsAsTaggableOn.taggings_table, :tag_id
9
+ add_index ActsAsTaggableOn.taggings_table, :taggable_id unless index_exists? ActsAsTaggableOn.taggings_table, :taggable_id
10
+ add_index ActsAsTaggableOn.taggings_table, :taggable_type unless index_exists? ActsAsTaggableOn.taggings_table, :taggable_type
11
+ add_index ActsAsTaggableOn.taggings_table, :tagger_id unless index_exists? ActsAsTaggableOn.taggings_table, :tagger_id
12
+ add_index ActsAsTaggableOn.taggings_table, :context unless index_exists? ActsAsTaggableOn.taggings_table, :context
13
+
14
+ unless index_exists? ActsAsTaggableOn.taggings_table, [:tagger_id, :tagger_type]
15
+ add_index ActsAsTaggableOn.taggings_table, [:tagger_id, :tagger_type]
16
+ end
17
+
18
+ unless index_exists? ActsAsTaggableOn.taggings_table, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
19
+ add_index ActsAsTaggableOn.taggings_table, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
20
+ end
21
+ end
22
+ end
@@ -1,15 +1,21 @@
1
- # This file was generated by Appraisal
2
-
3
1
  source "https://rubygems.org"
4
2
 
5
- gem "activerecord", "~> 5.0.0"
3
+ gem "activerecord", "~> 5.0.3"
4
+ case ENV["DB"]
5
+ when "postgresql"
6
+ gem 'pg'
7
+ when "mysql"
8
+ gem 'mysql2', '~> 0.3'
9
+ else
10
+ gem "sqlite3", "~> 1.3", "< 1.4"
11
+ end
6
12
 
7
13
  group :local_development do
8
14
  gem "guard"
9
15
  gem "guard-rspec"
10
16
  gem "appraisal"
11
17
  gem "rake"
12
- gem "byebug", :platforms => [:mri_21, :mri_22, :mri_23]
18
+ gem "byebug", platforms: [:mri]
13
19
  end
14
20
 
15
- gemspec :path => "../"
21
+ gemspec path: "../"
@@ -0,0 +1,21 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "activerecord", "~> 5.1.1"
4
+ case ENV["DB"]
5
+ when "postgresql"
6
+ gem 'pg'
7
+ when "mysql"
8
+ gem 'mysql2', '~> 0.3'
9
+ else
10
+ gem "sqlite3", "~> 1.3", "< 1.4"
11
+ end
12
+
13
+ group :local_development do
14
+ gem "guard"
15
+ gem "guard-rspec"
16
+ gem "appraisal"
17
+ gem "rake"
18
+ gem "byebug", platforms: [:mri]
19
+ end
20
+
21
+ gemspec path: "../"