diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2017-04-06 01:53:57 +0300 |
---|---|---|
committer | blackst0ne <blackst0ne.ru@gmail.com> | 2017-04-06 01:53:57 +0300 |
commit | 9997c58fc0db6469cde1a21428e050aa7b550a9a (patch) | |
tree | c43d6edeb2a764f1b046270d343477369977c6ce /doc/development/migration_style_guide.md | |
parent | d9aca741155f456711e37ea68a28a46d349af698 (diff) |
Add remove_concurrent_index to database helper
Diffstat (limited to 'doc/development/migration_style_guide.md')
-rw-r--r-- | doc/development/migration_style_guide.md | 16 |
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 |