diff --git a/db/migrate/20170503184421_add_index_to_redirect_routes.rb b/db/migrate/20170503184421_add_index_to_redirect_routes.rb new file mode 100644 index 0000000000000000000000000000000000000000..5991f6ab6a11aab26c692813043bc7d9fe07443f --- /dev/null +++ b/db/migrate/20170503184421_add_index_to_redirect_routes.rb @@ -0,0 +1,22 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +# rubocop:disable RemoveIndex +class AddIndexToRedirectRoutes < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index(:redirect_routes, :path, unique: true) + add_concurrent_index(:redirect_routes, [:source_type, :source_id]) + end + + def down + remove_index(:redirect_routes, :path) if index_exists?(:redirect_routes, :path) + remove_index(:redirect_routes, [:source_type, :source_id]) if index_exists?(:redirect_routes, [:source_type, :source_id]) + end +end diff --git a/db/schema.rb b/db/schema.rb index 3a8970b2235e8a61d0477932f16a681f2303fd99..45c3b9a4c917cab4aabae04e421e332cd441c8f1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1048,6 +1048,9 @@ ActiveRecord::Schema.define(version: 20170504102911) do t.datetime "updated_at", null: false end + add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path", unique: true, using: :btree + add_index "redirect_routes", ["source_type", "source_id"], name: "index_redirect_routes_on_source_type_and_source_id", using: :btree + create_table "releases", force: :cascade do |t| t.string "tag" t.text "description" @@ -1423,4 +1426,4 @@ ActiveRecord::Schema.define(version: 20170504102911) do add_foreign_key "timelogs", "merge_requests", name: "fk_timelogs_merge_requests_merge_request_id", on_delete: :cascade add_foreign_key "trending_projects", "projects", on_delete: :cascade add_foreign_key "u2f_registrations", "users" -end \ No newline at end of file +end