diff options
-rw-r--r-- | db/migrate/20170503184421_add_index_to_redirect_routes.rb | 22 | ||||
-rw-r--r-- | db/schema.rb | 5 |
2 files changed, 26 insertions, 1 deletions
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 00000000000..5991f6ab6a1 --- /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 3a8970b2235..45c3b9a4c91 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 |