summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-04-06 10:54:09 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2017-04-06 10:54:09 +0000
commitdc20dd1b3d69bfcd503f4dfe1b89f49bf7083844 (patch)
tree0080795810d35881352af23d3ef495af66eed1f9 /doc
parent9c2979ecdf7f65419232c0193389e3cccca27ba5 (diff)
parent9997c58fc0db6469cde1a21428e050aa7b550a9a (diff)
downloadgitlab-ce-dc20dd1b3d69bfcd503f4dfe1b89f49bf7083844.tar.gz
Merge branch 'add_remove_concurrent_index_to_database_helper' into 'master'
Add remove_concurrent_index to database helper Closes #30376 See merge request !10441
Diffstat (limited to 'doc')
-rw-r--r--doc/development/migration_style_guide.md16
1 files changed, 14 insertions, 2 deletions
diff --git a/doc/development/migration_style_guide.md b/doc/development/migration_style_guide.md
index fd8335d251e..587922d0136 100644
--- a/doc/development/migration_style_guide.md
+++ b/doc/development/migration_style_guide.md
@@ -58,10 +58,22 @@ migration was tested.
## Removing indices
-If you need to remove index, please add a condition like in following example:
+When removing an index make sure to use the method `remove_concurrent_index` instead
+of the regular `remove_index` method. The `remove_concurrent_index` method
+automatically drops concurrent indexes when using PostgreSQL, removing the
+need for downtime. To use this method you must disable transactions by calling
+the method `disable_ddl_transaction!` in the body of your migration class like
+so:
```ruby
-remove_index :namespaces, column: :name if index_exists?(:namespaces, :name)
+class MyMigration < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index :table_name, :column_name if index_exists?(:table_name, :column_name)
+ end
+end
```
## Adding indices