diff options
author | Stan Hu <stanhu@gmail.com> | 2015-04-27 06:09:20 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-04-27 06:09:20 -0700 |
commit | 44afcd2019d3c1c77c91f24a08e657331568c39f (patch) | |
tree | ba783ed603b090cbf371fb0b6fe79cf61edad100 /db/migrate/20150425164649_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb | |
parent | 278c3ba401efc68b6454abc2d530d813f2a9ffec (diff) | |
download | gitlab-ce-44afcd2019d3c1c77c91f24a08e657331568c39f.tar.gz |
Fix DB error when trying to tag a repository
Upon tagging a repository, an error due to a missing migration occurred:
```
PG::Error: ERROR: column "taggings_count" does not exist
LINE 1: UPDATE "tags" SET "taggings_count" = COALESCE("taggings_coun...
```
Ran `rake acts_as_taggable_on_engine:install:migrations`, removed the first
migration that created the `tags` and `taggings` table, and added the rest.
Closes #1512
Closes https://github.com/gitlabhq/gitlabhq/issues/6867
Closes https://github.com/gitlabhq/gitlabhq/issues/9194
Diffstat (limited to 'db/migrate/20150425164649_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb')
-rw-r--r-- | db/migrate/20150425164649_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/db/migrate/20150425164649_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb b/db/migrate/20150425164649_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb new file mode 100644 index 00000000000..8edb5080781 --- /dev/null +++ b/db/migrate/20150425164649_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb @@ -0,0 +1,15 @@ +# This migration comes from acts_as_taggable_on_engine (originally 3) +class AddTaggingsCounterCacheToTags < ActiveRecord::Migration + def self.up + add_column :tags, :taggings_count, :integer, default: 0 + + ActsAsTaggableOn::Tag.reset_column_information + ActsAsTaggableOn::Tag.find_each do |tag| + ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings) + end + end + + def self.down + remove_column :tags, :taggings_count + end +end |