Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 18:09:21 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 18:09:21 +0300
commitc36152ff8c41fad2f413f253eb7ac5c927e47c56 (patch)
treebbf300da207de3e8bbf272d44111ceedb18f5833 /doc/development/migration_style_guide.md
parent286fe61013674fe2d245ffc8d2233baf09923e70 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/development/migration_style_guide.md')
-rw-r--r--doc/development/migration_style_guide.md28
1 files changed, 24 insertions, 4 deletions
diff --git a/doc/development/migration_style_guide.md b/doc/development/migration_style_guide.md
index 3f202115b4c..776ac252b76 100644
--- a/doc/development/migration_style_guide.md
+++ b/doc/development/migration_style_guide.md
@@ -176,9 +176,15 @@ Removing a column:
```ruby
include Gitlab::Database::MigrationHelpers
-def change
+def up
with_lock_retries do
- remove_column :users, :full_name, :string
+ remove_column :users, :full_name
+ end
+end
+
+def down
+ with_lock_retries do
+ add_column :users, :full_name, :string
end
end
```
@@ -188,11 +194,17 @@ Removing a foreign key:
```ruby
include Gitlab::Database::MigrationHelpers
-def change
+def up
with_lock_retries do
remove_foreign_key :issues, :projects
end
end
+
+def down
+ with_lock_retries do
+ add_foreign_key :issues, :projects
+ end
+end
```
Changing default value for a column:
@@ -200,11 +212,17 @@ Changing default value for a column:
```ruby
include Gitlab::Database::MigrationHelpers
-def change
+def up
with_lock_retries do
change_column_default :merge_requests, :lock_version, from: nil, to: 0
end
end
+
+def down
+ with_lock_retries do
+ change_column_default :merge_requests, :lock_version, from: 0, to: nil
+ end
+end
```
### When to use the helper method
@@ -231,6 +249,8 @@ Example changes:
**Note:** `with_lock_retries` method **cannot** be used with `disable_ddl_transaction!`.
+**Note:** `with_lock_retries` method **cannot** be used within the `change` method, you must manually define the `up` and `down` methods to make the migration reversible.
+
### How the helper method works
1. Iterate 50 times.