-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from rueckerl/master
Replaced ActsAsTaggableOnSteroids with ActsAsTaggableOn.
- Loading branch information
Showing
52 changed files
with
120 additions
and
1,778 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ def comment_count | |
end | ||
|
||
def tag_count | ||
Tag.count | ||
ActsAsTaggableOn::Tag.count | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
class UpdateTaggingTables < ActiveRecord::Migration | ||
def up | ||
#update tables | ||
change_column_null :tags, :taggings_count, true | ||
|
||
change_table :taggings do |t| | ||
#t.references :tag | ||
|
||
# You should make sure that the column created is | ||
# long enough to store the required class names. | ||
# t.references :taggable, polymorphic: true | ||
t.references :tagger, polymorphic: true | ||
t.string :taggable_type, null: false, default: 'Post' | ||
|
||
# Limit is created to prevent MySQL error on index | ||
# length for MyISAM table type: http://bit.ly/vgW2Ql | ||
t.string :context, limit: 128, default: 'tags', null: false | ||
|
||
#t.datetime :created_at | ||
end | ||
# set default before to force the db filling this field | ||
change_column_default(:taggings, :taggable_type, nil) | ||
change_column_default(:taggings, :context, nil) | ||
|
||
if ActsAsTaggableOn::Utils.using_mysql? | ||
execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;") | ||
end | ||
|
||
#drop old index structures | ||
ActiveRecord::Base.connection.indexes(:taggings).each do |index| | ||
remove_index :taggings, :name => index.name | ||
end | ||
ActiveRecord::Base.connection.indexes(:tags).each do |index| | ||
remove_index :tags, :name => index.name | ||
end | ||
|
||
#create new index structures | ||
|
||
add_index :tags, :name, unique: true | ||
add_index :taggings, | ||
[:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type], | ||
unique: true, name: 'taggings_idx' | ||
add_index :taggings, [:taggable_id, :taggable_type, :context] | ||
|
||
#update data | ||
#TODO: test what this really does | ||
ActsAsTaggableOn::Tag.reset_column_information | ||
ActsAsTaggableOn::Tag.find_each do |tag| | ||
ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings) | ||
end | ||
end | ||
|
||
def down | ||
raise ActiveRecord::IrreversibleMigration | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.