Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing unique indices #343

Merged
merged 3 commits into from
Dec 10, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.