From 44afcd2019d3c1c77c91f24a08e657331568c39f Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Mon, 27 Apr 2015 06:09:20 -0700 Subject: 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 --- ...sing_unique_indices.acts_as_taggable_on_engine.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 db/migrate/20150425164648_add_missing_unique_indices.acts_as_taggable_on_engine.rb (limited to 'db/migrate/20150425164648_add_missing_unique_indices.acts_as_taggable_on_engine.rb') diff --git a/db/migrate/20150425164648_add_missing_unique_indices.acts_as_taggable_on_engine.rb b/db/migrate/20150425164648_add_missing_unique_indices.acts_as_taggable_on_engine.rb new file mode 100644 index 00000000000..4ca676f6c72 --- /dev/null +++ b/db/migrate/20150425164648_add_missing_unique_indices.acts_as_taggable_on_engine.rb @@ -0,0 +1,20 @@ +# This migration comes from acts_as_taggable_on_engine (originally 2) +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: 'taggings_idx' + add_index :taggings, :tag_id + add_index :taggings, [:taggable_id, :taggable_type, :context] + end +end -- cgit v1.2.1