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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
66562408
Commit
66562408
authored
Jan 23, 2020
by
Jarka Košanová
Committed by
Mayra Cabrera
Jan 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove invalid data from jira_tracker_data table
- this removes the invalid data - follow-up will reinsert them
parent
3910bac9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
1 deletion
+101
-1
changelogs/unreleased/198030-fix-wrong-data.yml
changelogs/unreleased/198030-fix-wrong-data.yml
+5
-0
db/post_migrate/20200123155929_remove_invalid_jira_data.rb
db/post_migrate/20200123155929_remove_invalid_jira_data.rb
+25
-0
db/schema.rb
db/schema.rb
+1
-1
spec/migrations/20200123155929_remove_invalid_jira_data_spec.rb
...igrations/20200123155929_remove_invalid_jira_data_spec.rb
+70
-0
No files found.
changelogs/unreleased/198030-fix-wrong-data.yml
0 → 100644
View file @
66562408
---
title
:
Remove invalid data from jira_tracker_data table
merge_request
:
23621
author
:
type
:
fixed
db/post_migrate/20200123155929_remove_invalid_jira_data.rb
0 → 100644
View file @
66562408
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
RemoveInvalidJiraData
<
ActiveRecord
::
Migration
[
5.2
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
up
sql
=
"DELETE FROM jira_tracker_data WHERE \
(length(encrypted_api_url) > 0 AND encrypted_api_url_iv IS NULL) \
OR (length(encrypted_url) > 0 AND encrypted_url_iv IS NULL) \
OR (length(encrypted_username) > 0 AND encrypted_username_iv IS NULL) \
OR (length(encrypted_password) > 0 AND encrypted_password_iv IS NULL)"
execute
(
sql
)
end
def
down
# We need to figure out why migrating data to jira_tracker_data table
# failed and then can recreate the data
end
end
db/schema.rb
View file @
66562408
...
...
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2020_01_2
1_132641
)
do
ActiveRecord
::
Schema
.
define
(
version:
2020_01_2
3_155929
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"pg_trgm"
...
...
spec/migrations/20200123155929_remove_invalid_jira_data_spec.rb
0 → 100644
View file @
66562408
# frozen_string_literal: true
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20200123155929_remove_invalid_jira_data.rb'
)
describe
RemoveInvalidJiraData
,
:migration
do
let
(
:jira_tracker_data
)
{
table
(
:jira_tracker_data
)
}
let
(
:services
)
{
table
(
:services
)
}
let
(
:service
)
{
services
.
create
(
id:
1
)
}
let
(
:data
)
do
{
service_id:
service
.
id
,
encrypted_api_url:
'http:url.com'
,
encrypted_api_url_iv:
'somevalue'
,
encrypted_url:
'http:url.com'
,
encrypted_url_iv:
'somevalue'
,
encrypted_username:
'username'
,
encrypted_username_iv:
'somevalue'
,
encrypted_password:
'username'
,
encrypted_password_iv:
'somevalue'
}
end
let!
(
:valid_data
)
{
jira_tracker_data
.
create
(
data
)
}
let!
(
:empty_data
)
{
jira_tracker_data
.
create
(
service_id:
service
.
id
)
}
let!
(
:invalid_api_url
)
do
data
[
:encrypted_api_url_iv
]
=
nil
jira_tracker_data
.
create
(
data
)
end
let!
(
:missing_api_url
)
do
data
[
:encrypted_api_url
]
=
''
data
[
:encrypted_api_url_iv
]
=
nil
jira_tracker_data
.
create
(
data
)
end
let!
(
:invalid_url
)
do
data
[
:encrypted_url_iv
]
=
nil
jira_tracker_data
.
create
(
data
)
end
let!
(
:missing_url
)
do
data
[
:encrypted_url
]
=
''
jira_tracker_data
.
create
(
data
)
end
let!
(
:invalid_username
)
do
data
[
:encrypted_username_iv
]
=
nil
jira_tracker_data
.
create
(
data
)
end
let!
(
:missing_username
)
do
data
[
:encrypted_username
]
=
nil
data
[
:encrypted_username_iv
]
=
nil
jira_tracker_data
.
create
(
data
)
end
let!
(
:invalid_password
)
do
data
[
:encrypted_password_iv
]
=
nil
jira_tracker_data
.
create
(
data
)
end
let!
(
:missing_password
)
do
data
[
:encrypted_password
]
=
nil
data
[
:encrypted_username_iv
]
=
nil
jira_tracker_data
.
create
(
data
)
end
it
'removes the invalid data'
do
valid_data_records
=
[
valid_data
,
empty_data
,
missing_api_url
,
missing_url
,
missing_username
,
missing_password
]
expect
{
migrate!
}.
to
change
{
jira_tracker_data
.
count
}.
from
(
10
).
to
(
6
)
expect
(
jira_tracker_data
.
all
).
to
match_array
(
valid_data_records
)
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