Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
7733e8c3
Commit
7733e8c3
authored
Sep 13, 2017
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add migration to fix corrupted projects
parent
05cb1816
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
3 deletions
+47
-3
db/post_migrate/20170913150359_change_project_id_to_not_null_in_project_features.rb
...0359_change_project_id_to_not_null_in_project_features.rb
+15
-0
db/post_migrate/20170913180600_fix_projects_without_project_feature.rb
...te/20170913180600_fix_projects_without_project_feature.rb
+29
-0
db/schema.rb
db/schema.rb
+2
-2
spec/services/projects/update_service_spec.rb
spec/services/projects/update_service_spec.rb
+1
-1
No files found.
db/post_migrate/20170913150359_change_project_id_to_not_null_in_project_features.rb
0 → 100644
View file @
7733e8c3
class
ChangeProjectIdToNotNullInProjectFeatures
<
ActiveRecord
::
Migration
DOWNTIME
=
false
def
up
# Deletes corrupted project features
delete_project_features_sql
=
"DELETE FROM project_features WHERE project_id IS NULL"
execute
(
delete_project_features_sql
)
change_column_null
:project_features
,
:project_id
,
false
end
def
down
change_column_null
:project_features
,
:project_id
,
true
end
end
db/post_migrate/20170913180600_fix_projects_without_project_feature.rb
0 → 100644
View file @
7733e8c3
class
FixProjectsWithoutProjectFeature
<
ActiveRecord
::
Migration
DOWNTIME
=
false
def
up
# 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
db/schema.rb
View file @
7733e8c3
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20170
824162758
)
do
ActiveRecord
::
Schema
.
define
(
version:
20170
913180600
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
@@ -1113,7 +1113,7 @@ ActiveRecord::Schema.define(version: 20170824162758) do
...
@@ -1113,7 +1113,7 @@ ActiveRecord::Schema.define(version: 20170824162758) do
add_index
"project_authorizations"
,
[
"user_id"
,
"project_id"
,
"access_level"
],
name:
"index_project_authorizations_on_user_id_project_id_access_level"
,
unique:
true
,
using: :btree
add_index
"project_authorizations"
,
[
"user_id"
,
"project_id"
,
"access_level"
],
name:
"index_project_authorizations_on_user_id_project_id_access_level"
,
unique:
true
,
using: :btree
create_table
"project_features"
,
force: :cascade
do
|
t
|
create_table
"project_features"
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
t
.
integer
"project_id"
,
null:
false
t
.
integer
"merge_requests_access_level"
t
.
integer
"merge_requests_access_level"
t
.
integer
"issues_access_level"
t
.
integer
"issues_access_level"
t
.
integer
"wiki_access_level"
t
.
integer
"wiki_access_level"
...
...
spec/services/projects/update_service_spec.rb
View file @
7733e8c3
...
@@ -58,7 +58,7 @@ describe Projects::UpdateService, '#execute' do
...
@@ -58,7 +58,7 @@ describe Projects::UpdateService, '#execute' do
end
end
end
end
context
'
W
hen project visibility is higher than parent group'
do
context
'
w
hen project visibility is higher than parent group'
do
let
(
:group
)
{
create
(
:group
,
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
)
}
let
(
:group
)
{
create
(
:group
,
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
)
}
before
do
before
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment