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
dfdf22c7
Commit
dfdf22c7
authored
Dec 27, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix PostgreSQL implementation of migration
parent
5cacdc4e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
3 deletions
+5
-3
sh-fix-mysql-migration-10-3.yml
changelogs/unreleased/sh-fix-mysql-migration-10-3.yml
+1
-1
20171106151218_issues_moved_to_id_foreign_key.rb
db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb
+3
-1
issues_moved_to_id_foreign_key_spec.rb
spec/migrations/issues_moved_to_id_foreign_key_spec.rb
+1
-1
No files found.
changelogs/unreleased/sh-fix-mysql-migration-10-3.yml
View file @
dfdf22c7
---
---
title
:
Fix migration for removing orphaned issues.moved_to_id values in MySQL
title
:
Fix migration for removing orphaned issues.moved_to_id values in MySQL
and PostgreSQL
merge_request
:
merge_request
:
author
:
author
:
type
:
fixed
type
:
fixed
db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb
View file @
dfdf22c7
...
@@ -15,7 +15,9 @@ class IssuesMovedToIdForeignKey < ActiveRecord::Migration
...
@@ -15,7 +15,9 @@ class IssuesMovedToIdForeignKey < ActiveRecord::Migration
self
.
table_name
=
'issues'
self
.
table_name
=
'issues'
def
self
.
with_orphaned_moved_to_issues
def
self
.
with_orphaned_moved_to_issues
where
(
'NOT EXISTS (SELECT true FROM issues WHERE issues.id = issues.moved_to_id)'
)
# Be careful to use a second table here for comparison otherwise we'll null
# out all rows that don't have id == moved_to_id!
where
(
'NOT EXISTS (SELECT true FROM issues b WHERE issues.moved_to_id = b.id)'
)
.
where
(
'moved_to_id IS NOT NULL'
)
.
where
(
'moved_to_id IS NOT NULL'
)
end
end
end
end
...
...
spec/migrations/issues_moved_to_id_foreign_key_spec.rb
View file @
dfdf22c7
...
@@ -4,7 +4,7 @@ require Rails.root.join('db', 'migrate', '20171106151218_issues_moved_to_id_fore
...
@@ -4,7 +4,7 @@ require Rails.root.join('db', 'migrate', '20171106151218_issues_moved_to_id_fore
# The schema version has to be far enough in advance to have the
# The schema version has to be far enough in advance to have the
# only_mirror_protected_branches column in the projects table to create a
# only_mirror_protected_branches column in the projects table to create a
# project via FactoryBot.
# project via FactoryBot.
describe
IssuesMovedToIdForeignKey
,
:migration
,
schema:
201711
09115718
do
describe
IssuesMovedToIdForeignKey
,
:migration
,
schema:
201711
14150259
do
let!
(
:issue_first
)
{
create
(
:issue
,
moved_to_id:
issue_second
.
id
)
}
let!
(
:issue_first
)
{
create
(
:issue
,
moved_to_id:
issue_second
.
id
)
}
let!
(
:issue_second
)
{
create
(
:issue
,
moved_to_id:
issue_third
.
id
)
}
let!
(
:issue_second
)
{
create
(
:issue
,
moved_to_id:
issue_third
.
id
)
}
let!
(
:issue_third
)
{
create
(
:issue
)
}
let!
(
:issue_third
)
{
create
(
:issue
)
}
...
...
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