diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2017-09-16 08:09:20 +0300 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-09-19 09:48:30 +0300 |
commit | a0673b38bc05e795a8dd647239288e13d0ea9d10 (patch) | |
tree | 5d9117f0182ad4bda7e74b794209dca521fdfa1e /db/post_migrate | |
parent | c56c4170092a4afbd2660fccc2738ebfdcb559f9 (diff) |
Merge branch 'issue_37640' into 'master'
Fix project feature being deleted when updating project with invalid visibility level
Closes #37640
See merge request gitlab-org/gitlab-ce!14234
Diffstat (limited to 'db/post_migrate')
-rw-r--r-- | db/post_migrate/20170913180600_fix_projects_without_project_feature.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/db/post_migrate/20170913180600_fix_projects_without_project_feature.rb b/db/post_migrate/20170913180600_fix_projects_without_project_feature.rb new file mode 100644 index 00000000000..bfa9ad80c7d --- /dev/null +++ b/db/post_migrate/20170913180600_fix_projects_without_project_feature.rb @@ -0,0 +1,33 @@ +class FixProjectsWithoutProjectFeature < ActiveRecord::Migration + DOWNTIME = false + + def up + # Deletes corrupted project features + sql = "DELETE FROM project_features WHERE project_id IS NULL" + execute(sql) + + # Creates missing project features with private visibility + sql = + %Q{ + INSERT INTO project_features(project_id, repository_access_level, issues_access_level, merge_requests_access_level, wiki_access_level, + builds_access_level, snippets_access_level, created_at, updated_at) + SELECT projects.id as project_id, + 10 as repository_access_level, + 10 as issues_access_level, + 10 as merge_requests_access_level, + 10 as wiki_access_level, + 10 as builds_access_level , + 10 as snippets_access_level, + projects.created_at, + projects.updated_at + FROM projects + LEFT OUTER JOIN project_features ON project_features.project_id = projects.id + WHERE (project_features.id IS NULL) + } + + execute(sql) + end + + def down + end +end |