diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-08-03 20:21:22 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-08-17 18:58:58 +0300 |
commit | c14ac835756d1d0f4d0f8279759e2b7f75364447 (patch) | |
tree | 925000dd60d64676eb76b8d4830ee7a9001a9a4f /db | |
parent | c08a14c3c20de35018a36f89dec0b10c99a4fd86 (diff) |
Ensure that we have only one list per label per board
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20160803161903_add_unique_index_to_lists_label_id.rb | 15 | ||||
-rw-r--r-- | db/schema.rb | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/db/migrate/20160803161903_add_unique_index_to_lists_label_id.rb b/db/migrate/20160803161903_add_unique_index_to_lists_label_id.rb new file mode 100644 index 00000000000..baf2e70b127 --- /dev/null +++ b/db/migrate/20160803161903_add_unique_index_to_lists_label_id.rb @@ -0,0 +1,15 @@ +class AddUniqueIndexToListsLabelId < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :lists, [:board_id, :label_id], unique: true + end + + def down + remove_index :lists, column: [:board_id, :label_id] if index_exists?(:lists, [:board_id, :label_id], unique: true) + end +end diff --git a/db/schema.rb b/db/schema.rb index 873dfa81702..0cdcc080227 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -550,6 +550,7 @@ ActiveRecord::Schema.define(version: 20160810142633) do t.datetime "updated_at", null: false end + add_index "lists", ["board_id", "label_id"], name: "index_lists_on_board_id_and_label_id", unique: true, using: :btree add_index "lists", ["board_id"], name: "index_lists_on_board_id", using: :btree add_index "lists", ["label_id"], name: "index_lists_on_label_id", using: :btree |