summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2017-03-01 11:53:39 +0200
committerValery Sizov <valery@gitlab.com>2017-03-01 11:53:39 +0200
commit30a8b4ce32635f87921a9a71c71c493330239d6e (patch)
tree2ce02ce6d6381445f50b1e5071974d6b5134f5fc
parent05c8ec6cb85a3943b53cbd5757e7baea300dac68 (diff)
downloadgitlab-ce-label-link-uniquw-index.tar.gz
Validate uniquness of labels for issues and MRs on database levellabel-link-uniquw-index
-rw-r--r--db/migrate/20170228212410_remove_target_id_target_type_index.rb29
-rw-r--r--db/migrate/20170228212813_add_target_id_target_type_label_id_unique_index.rb29
-rw-r--r--db/schema.rb20
3 files changed, 69 insertions, 9 deletions
diff --git a/db/migrate/20170228212410_remove_target_id_target_type_index.rb b/db/migrate/20170228212410_remove_target_id_target_type_index.rb
new file mode 100644
index 00000000000..a0eb1c35fd7
--- /dev/null
+++ b/db/migrate/20170228212410_remove_target_id_target_type_index.rb
@@ -0,0 +1,29 @@
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class RemoveTargetIdTargetTypeIndex < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ # When a migration requires downtime you **must** uncomment the following
+ # constant and define a short and easy to understand explanation as to why the
+ # migration requires downtime.
+ # DOWNTIME_REASON = ''
+
+ # When using the methods "add_concurrent_index" or "add_column_with_default"
+ # you must disable the use of transactions as these methods can not run in an
+ # existing transaction. When using "add_concurrent_index" make sure that this
+ # method is the _only_ method called in the migration, any other changes
+ # should go in a separate migration. This ensures that upon failure _only_ the
+ # index creation fails and can be retried or reverted easily.
+ #
+ # To disable transactions uncomment the following line and remove these
+ # comments:
+ # disable_ddl_transaction!
+
+ def change
+ remove_index :label_links, column: ["target_id", "target_type"] if index_exists?(:label_links, ["target_id", "target_type"])
+ end
+end
diff --git a/db/migrate/20170228212813_add_target_id_target_type_label_id_unique_index.rb b/db/migrate/20170228212813_add_target_id_target_type_label_id_unique_index.rb
new file mode 100644
index 00000000000..ced057a13df
--- /dev/null
+++ b/db/migrate/20170228212813_add_target_id_target_type_label_id_unique_index.rb
@@ -0,0 +1,29 @@
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddTargetIdTargetTypeLabelIdUniqueIndex < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ # When a migration requires downtime you **must** uncomment the following
+ # constant and define a short and easy to understand explanation as to why the
+ # migration requires downtime.
+ # DOWNTIME_REASON = ''
+
+ # When using the methods "add_concurrent_index" or "add_column_with_default"
+ # you must disable the use of transactions as these methods can not run in an
+ # existing transaction. When using "add_concurrent_index" make sure that this
+ # method is the _only_ method called in the migration, any other changes
+ # should go in a separate migration. This ensures that upon failure _only_ the
+ # index creation fails and can be retried or reverted easily.
+ #
+ # To disable transactions uncomment the following line and remove these
+ # comments:
+ disable_ddl_transaction!
+
+ def change
+ add_concurrent_index 'label_links', ['target_id', 'target_type', 'label_id'], unique: true
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 1d94368f66e..8f30c16f0fe 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20170216141440) do
+ActiveRecord::Schema.define(version: 20170228212410) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -98,20 +98,20 @@ ActiveRecord::Schema.define(version: 20170216141440) do
t.text "help_page_text_html"
t.text "shared_runners_text_html"
t.text "after_sign_up_text_html"
+ t.boolean "sidekiq_throttling_enabled", default: false
+ t.string "sidekiq_throttling_queues"
+ t.decimal "sidekiq_throttling_factor"
t.boolean "housekeeping_enabled", default: true, null: false
t.boolean "housekeeping_bitmaps_enabled", default: true, null: false
t.integer "housekeeping_incremental_repack_period", default: 10, null: false
t.integer "housekeeping_full_repack_period", default: 50, null: false
t.integer "housekeeping_gc_period", default: 200, null: false
- t.boolean "sidekiq_throttling_enabled", default: false
- t.string "sidekiq_throttling_queues"
- t.decimal "sidekiq_throttling_factor"
t.boolean "html_emails_enabled", default: true
t.string "plantuml_url"
t.boolean "plantuml_enabled"
- t.integer "max_pages_size", default: 100, null: false
t.integer "terminal_max_session_time", default: 0, null: false
- t.string "default_artifacts_expire_in", default: '0', null: false
+ t.integer "max_pages_size", default: 100, null: false
+ t.string "default_artifacts_expire_in", default: "0", null: false
end
create_table "audit_events", force: :cascade do |t|
@@ -515,6 +515,7 @@ ActiveRecord::Schema.define(version: 20170216141440) do
t.text "title_html"
t.text "description_html"
t.integer "time_estimate"
+ t.integer "relative_position"
end
add_index "issues", ["assignee_id"], name: "index_issues_on_assignee_id", using: :btree
@@ -526,6 +527,7 @@ ActiveRecord::Schema.define(version: 20170216141440) do
add_index "issues", ["due_date"], name: "index_issues_on_due_date", using: :btree
add_index "issues", ["milestone_id"], name: "index_issues_on_milestone_id", using: :btree
add_index "issues", ["project_id", "iid"], name: "index_issues_on_project_id_and_iid", unique: true, using: :btree
+ add_index "issues", ["relative_position"], name: "index_issues_on_relative_position", using: :btree
add_index "issues", ["state"], name: "index_issues_on_state", using: :btree
add_index "issues", ["title"], name: "index_issues_on_title_trigram", using: :gin, opclasses: {"title"=>"gin_trgm_ops"}
@@ -554,7 +556,7 @@ ActiveRecord::Schema.define(version: 20170216141440) do
end
add_index "label_links", ["label_id"], name: "index_label_links_on_label_id", using: :btree
- add_index "label_links", ["target_id", "target_type"], name: "index_label_links_on_target_id_and_target_type", using: :btree
+ add_index "label_links", ["target_id", "target_type", "label_id"], name: "index_label_links_on_target_id_and_target_type_and_label_id", unique: true, using: :btree
create_table "label_priorities", force: :cascade do |t|
t.integer "project_id", null: false
@@ -581,9 +583,9 @@ ActiveRecord::Schema.define(version: 20170216141440) do
end
add_index "labels", ["group_id", "project_id", "title"], name: "index_labels_on_group_id_and_project_id_and_title", unique: true, using: :btree
- add_index "labels", ["type", "project_id"], name: "index_labels_on_type_and_project_id", using: :btree
add_index "labels", ["project_id"], name: "index_labels_on_project_id", using: :btree
add_index "labels", ["title"], name: "index_labels_on_title", using: :btree
+ add_index "labels", ["type", "project_id"], name: "index_labels_on_type_and_project_id", using: :btree
create_table "lfs_objects", force: :cascade do |t|
t.string "oid", null: false
@@ -1278,8 +1280,8 @@ ActiveRecord::Schema.define(version: 20170216141440) do
t.datetime "otp_grace_period_started_at"
t.boolean "ldap_email", default: false, null: false
t.boolean "external", default: false
- t.string "incoming_email_token"
t.string "organization"
+ t.string "incoming_email_token"
t.boolean "authorized_projects_populated"
t.boolean "notified_of_own_activity", default: false, null: false
t.boolean "ghost"