Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request mbleigh#343 from bf4/294-add-missing-indices
Browse files Browse the repository at this point in the history
[mbleigh#294] Add missing unique indices
  • Loading branch information
bf4 committed Dec 10, 2013
2 parents 37ad608 + a53fc30 commit bdc1d20
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 62 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ rails generate acts_as_taggable_on:migration
rake db:migrate
```

#### Upgrading

see [UPGRADING](UPGRADING)

## Testing

Acts As Taggable On uses RSpec for its test coverage. Inside the gem
Expand Down
7 changes: 7 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
When upgrading

Re-run the migrations generator

rake railties:install:migrations FROM=acts_as_taggable_on_engine db:migrate

It will create any new migrations and skip existing ones
21 changes: 21 additions & 0 deletions db/migrate/2_add_missing_unique_indices.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class AddMissingUniqueIndices < ActiveRecord::Migration

def self.up
add_index :tags, :name, unique: true

remove_index :taggings, :tag_id
remove_index :taggings, [:taggable_id, :taggable_type, :context]
add_index :taggings,
[:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
unique: true, name: 'taggings_idx'
end

def self.down
remove_index :tags, :name

remove_index :taggings, name: 'tagging_idx'
add_index :taggings, :tag_id
add_index :taggings, [:taggable_id, :taggable_type, :context]
end

end
2 changes: 1 addition & 1 deletion lib/acts-as-taggable-on.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def self.setup
require "acts_as_taggable_on/tag_list"
require "acts_as_taggable_on/tags_helper"
require "acts_as_taggable_on/tagging"
require 'acts_as_taggable_on/engine'

ActiveSupport.on_load(:active_record) do
extend ActsAsTaggableOn::Compatibility
Expand All @@ -57,4 +58,3 @@ def self.setup
ActiveSupport.on_load(:action_view) do
include ActsAsTaggableOn::TagsHelper
end

6 changes: 6 additions & 0 deletions lib/acts_as_taggable_on/engine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require 'rails/engine'
module ActsAsTaggableOn
class Engine < Rails::Engine

end
end

This file was deleted.

This file was deleted.

0 comments on commit bdc1d20

Please sign in to comment.