BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
fbaae9ff
Commit
fbaae9ff
authored
Aug 20, 2017
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'sh-fix-protected-tags-delete' into 'master'
Fix Error 500s when attempting to destroy a protected tag Closes #36013 See merge request !13692
parents
84336b84
718ecd4e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
2 deletions
+42
-2
20170820100558_correct_protected_tags_foreign_keys.rb
...ate/20170820100558_correct_protected_tags_foreign_keys.rb
+35
-0
schema.rb
db/schema.rb
+2
-2
migration_helpers.rb
lib/gitlab/database/migration_helpers.rb
+5
-0
No files found.
db/migrate/20170820100558_correct_protected_tags_foreign_keys.rb
0 → 100644
View file @
fbaae9ff
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
CorrectProtectedTagsForeignKeys
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME
=
false
disable_ddl_transaction!
def
up
remove_foreign_key_without_error
(
:protected_tag_create_access_levels
,
column: :protected_tag_id
)
execute
<<-
EOF
DELETE FROM protected_tag_create_access_levels
WHERE NOT EXISTS (
SELECT true
FROM protected_tags
WHERE protected_tag_create_access_levels.protected_tag_id = protected_tags.id
)
AND protected_tag_id IS NOT NULL
EOF
add_concurrent_foreign_key
(
:protected_tag_create_access_levels
,
:protected_tags
,
column: :protected_tag_id
)
end
def
down
# Previously there was a foreign key without a CASCADING DELETE, so we'll
# just leave the foreign key in place.
end
end
db/schema.rb
View file @
fbaae9ff
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201708
15060945
)
do
ActiveRecord
::
Schema
.
define
(
version:
201708
20100558
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -1726,7 +1726,7 @@ ActiveRecord::Schema.define(version: 20170815060945) do
add_foreign_key
"protected_branch_push_access_levels"
,
"protected_branches"
,
name:
"fk_9ffc86a3d9"
,
on_delete: :cascade
add_foreign_key
"protected_branches"
,
"projects"
,
name:
"fk_7a9c6d93e7"
,
on_delete: :cascade
add_foreign_key
"protected_tag_create_access_levels"
,
"namespaces"
,
column:
"group_id"
add_foreign_key
"protected_tag_create_access_levels"
,
"protected_tags"
add_foreign_key
"protected_tag_create_access_levels"
,
"protected_tags"
,
name:
"fk_f7dfda8c51"
,
on_delete: :cascade
add_foreign_key
"protected_tag_create_access_levels"
,
"users"
add_foreign_key
"protected_tags"
,
"projects"
,
name:
"fk_8e4af87648"
,
on_delete: :cascade
add_foreign_key
"push_event_payloads"
,
"events_for_migration"
,
column:
"event_id"
,
name:
"fk_36c74129da"
,
on_delete: :cascade
...
...
lib/gitlab/database/migration_helpers.rb
View file @
fbaae9ff
...
...
@@ -606,6 +606,11 @@ module Gitlab
Arel
::
Nodes
::
SqlLiteral
.
new
(
replace
.
to_sql
)
end
end
def
remove_foreign_key_without_error
(
*
args
)
remove_foreign_key
(
*
args
)
rescue
ArgumentError
end
end
end
end
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