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
f0a0da69
Commit
f0a0da69
authored
May 09, 2018
by
Douwe Maan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix-project-mirror-data-schema' into 'master'
Fix project mirror data schema See merge request gitlab-org/gitlab-ce!18811
parents
ee563bcb
c4957ea9
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
2 deletions
+78
-2
fix-project-mirror-data-schema.yml
changelogs/unreleased/fix-project-mirror-data-schema.yml
+6
-0
20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb
...not_null_constraint_to_project_mirror_data_foreign_key.rb
+21
-0
20180508102840_add_unique_constraint_to_project_mirror_data_project_id_index.rb
...que_constraint_to_project_mirror_data_project_id_index.rb
+31
-0
schema.rb
db/schema.rb
+2
-2
add_not_null_constraint_to_project_mirror_data_foreign_key_spec.rb
...ull_constraint_to_project_mirror_data_foreign_key_spec.rb
+18
-0
No files found.
changelogs/unreleased/fix-project-mirror-data-schema.yml
0 → 100644
View file @
f0a0da69
---
title
:
Fixes database inconsistencies between Community and Enterprise Edition on
import state
merge_request
:
18811
author
:
type
:
fixed
db/migrate/20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb
0 → 100644
View file @
f0a0da69
class
AddNotNullConstraintToProjectMirrorDataForeignKey
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
class
ProjectImportState
<
ActiveRecord
::
Base
include
EachBatch
self
.
table_name
=
'project_mirror_data'
end
def
up
ProjectImportState
.
where
(
project_id:
nil
).
delete_all
change_column_null
:project_mirror_data
,
:project_id
,
false
end
def
down
change_column_null
:project_mirror_data
,
:project_id
,
true
end
end
db/migrate/20180508102840_add_unique_constraint_to_project_mirror_data_project_id_index.rb
0 → 100644
View file @
f0a0da69
class
AddUniqueConstraintToProjectMirrorDataProjectIdIndex
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_concurrent_index
(
:project_mirror_data
,
:project_id
,
unique:
true
,
name:
'index_project_mirror_data_on_project_id_unique'
)
remove_concurrent_index_by_name
(
:project_mirror_data
,
'index_project_mirror_data_on_project_id'
)
rename_index
(
:project_mirror_data
,
'index_project_mirror_data_on_project_id_unique'
,
'index_project_mirror_data_on_project_id'
)
end
def
down
rename_index
(
:project_mirror_data
,
'index_project_mirror_data_on_project_id'
,
'index_project_mirror_data_on_project_id_old'
)
add_concurrent_index
(
:project_mirror_data
,
:project_id
)
remove_concurrent_index_by_name
(
:project_mirror_data
,
'index_project_mirror_data_on_project_id_old'
)
end
end
db/schema.rb
View file @
f0a0da69
...
...
@@ -1529,14 +1529,14 @@ ActiveRecord::Schema.define(version: 20180508135515) do
add_index
"project_import_data"
,
[
"project_id"
],
name:
"index_project_import_data_on_project_id"
,
using: :btree
create_table
"project_mirror_data"
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
t
.
integer
"project_id"
,
null:
false
t
.
string
"status"
t
.
string
"jid"
t
.
text
"last_error"
end
add_index
"project_mirror_data"
,
[
"jid"
],
name:
"index_project_mirror_data_on_jid"
,
using: :btree
add_index
"project_mirror_data"
,
[
"project_id"
],
name:
"index_project_mirror_data_on_project_id"
,
using: :btree
add_index
"project_mirror_data"
,
[
"project_id"
],
name:
"index_project_mirror_data_on_project_id"
,
u
nique:
true
,
u
sing: :btree
add_index
"project_mirror_data"
,
[
"status"
],
name:
"index_project_mirror_data_on_status"
,
using: :btree
create_table
"project_statistics"
,
force: :cascade
do
|
t
|
...
...
spec/migrations/add_not_null_constraint_to_project_mirror_data_foreign_key_spec.rb
0 → 100644
View file @
f0a0da69
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'migrate'
,
'20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb'
)
describe
AddNotNullConstraintToProjectMirrorDataForeignKey
,
:migration
do
let
(
:namespaces
)
{
table
(
:namespaces
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:import_state
)
{
table
(
:project_mirror_data
)
}
before
do
import_state
.
create!
(
id:
1
,
project_id:
nil
,
status: :started
)
end
it
'removes every import state without an associated project_id'
do
expect
do
subject
.
up
end
.
to
change
{
import_state
.
count
}.
from
(
1
).
to
(
0
)
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