diff options
author | Phil Hughes <me@iamphill.com> | 2016-08-30 13:49:31 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-08-30 13:49:31 +0100 |
commit | 172aab108b875e8dc9a5f1d3c2d53018eff76ea1 (patch) | |
tree | 068fa858eeaa8faa7c65f189d8189e33a83c86a3 /db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb | |
parent | 45fa7fd4ddf35314602168cd869ee4a67c44250b (diff) | |
parent | 2778dec131c2afac9fcdb2c42365b69099a5ae5b (diff) | |
download | gitlab-ce-172aab108b875e8dc9a5f1d3c2d53018eff76ea1.tar.gz |
Merge branch 'master' into autocomplete-space-prefix
Diffstat (limited to 'db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb')
-rw-r--r-- | db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb b/db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb new file mode 100644 index 00000000000..5c3e189bb5b --- /dev/null +++ b/db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb @@ -0,0 +1,29 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class MoveFromDevelopersCanPushToProtectedBranchesPushAccess < ActiveRecord::Migration + DOWNTIME = true + DOWNTIME_REASON = <<-HEREDOC + We're creating a `push_access_level` for each `protected_branch`. If a user creates a `protected_branch` while this + is running, we might be left with a `protected_branch` _without_ an associated `push_access_level`. The `protected_branches` + table must not change while this is running, so downtime is required. + + https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5081#note_13247410 + HEREDOC + + def up + execute <<-HEREDOC + INSERT into protected_branch_push_access_levels (protected_branch_id, access_level, created_at, updated_at) + SELECT id, (CASE WHEN developers_can_push THEN 30 ELSE 40 END), now(), now() + FROM protected_branches + HEREDOC + end + + def down + execute <<-HEREDOC + UPDATE protected_branches SET developers_can_push = TRUE + WHERE id IN (SELECT protected_branch_id FROM protected_branch_push_access_levels + WHERE access_level = 30); + HEREDOC + end +end |