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
67729cec
Commit
67729cec
authored
Mar 13, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test which would rollback db and migrate again
Closes #29106
parent
32da7602
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
26 additions
and
7 deletions
+26
-7
.gitlab-ci.yml
.gitlab-ci.yml
+7
-0
db/migrate/20160919145149_add_group_id_to_labels.rb
db/migrate/20160919145149_add_group_id_to_labels.rb
+1
-1
db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb
...0161020083353_add_pipeline_id_to_merge_request_metrics.rb
+1
-1
db/migrate/20161031171301_add_project_id_to_subscriptions.rb
db/migrate/20161031171301_add_project_id_to_subscriptions.rb
+1
-0
db/migrate/20161207231621_create_environment_name_unique_index.rb
...te/20161207231621_create_environment_name_unique_index.rb
+2
-2
db/migrate/20161209153400_add_unique_index_for_environment_slug.rb
...e/20161209153400_add_unique_index_for_environment_slug.rb
+1
-1
db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb
db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb
+10
-0
db/migrate/20170216141440_drop_index_for_builds_project_status.rb
...te/20170216141440_drop_index_for_builds_project_status.rb
+1
-1
db/post_migrate/20170206101007_remove_trackable_columns_from_timelogs.rb
.../20170206101007_remove_trackable_columns_from_timelogs.rb
+2
-1
No files found.
.gitlab-ci.yml
View file @
67729cec
...
...
@@ -222,6 +222,13 @@ rake db:migrate:reset:
script
:
-
bundle exec rake db:migrate:reset
rake db:rollback:
stage
:
test
<<
:
*use-db
<<
:
*dedicated-runner
script
:
-
bundle exec rake db:rollback db:migrate STEP=120
rake db:seed_fu:
stage
:
test
<<
:
*use-db
...
...
db/migrate/20160919145149_add_group_id_to_labels.rb
View file @
67729cec
...
...
@@ -12,8 +12,8 @@ class AddGroupIdToLabels < ActiveRecord::Migration
end
def
down
remove_foreign_key
:labels
,
column: :group_id
remove_index
:labels
,
:group_id
if
index_exists?
:labels
,
:group_id
remove_foreign_key
:labels
,
:namespaces
,
column: :group_id
remove_column
:labels
,
:group_id
end
end
db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb
View file @
67729cec
...
...
@@ -32,8 +32,8 @@ class AddPipelineIdToMergeRequestMetrics < ActiveRecord::Migration
end
def
down
remove_foreign_key
:merge_request_metrics
,
column: :pipeline_id
remove_index
:merge_request_metrics
,
:pipeline_id
if
index_exists?
:merge_request_metrics
,
:pipeline_id
remove_foreign_key
:merge_request_metrics
,
:ci_commits
,
column: :pipeline_id
remove_column
:merge_request_metrics
,
:pipeline_id
end
end
db/migrate/20161031171301_add_project_id_to_subscriptions.rb
View file @
67729cec
...
...
@@ -9,6 +9,7 @@ class AddProjectIdToSubscriptions < ActiveRecord::Migration
end
def
down
remove_foreign_key
:subscriptions
,
column: :project_id
remove_column
:subscriptions
,
:project_id
end
end
db/migrate/20161207231621_create_environment_name_unique_index.rb
View file @
67729cec
...
...
@@ -12,7 +12,7 @@ class CreateEnvironmentNameUniqueIndex < ActiveRecord::Migration
end
def
down
remove_index
:environments
,
[
:project_id
,
:name
]
,
unique:
true
add_concurrent_index
:environments
,
[
:project_id
,
:name
]
remove_index
:environments
,
[
:project_id
,
:name
]
add_concurrent_index
:environments
,
[
:project_id
,
:name
]
,
unique:
true
end
end
db/migrate/20161209153400_add_unique_index_for_environment_slug.rb
View file @
67729cec
...
...
@@ -14,6 +14,6 @@ class AddUniqueIndexForEnvironmentSlug < ActiveRecord::Migration
end
def
down
remove_index
:environments
,
[
:project_id
,
:slug
]
,
unique:
true
if
index_exists?
:environments
,
[
:project_id
,
:slug
]
remove_index
:environments
,
[
:project_id
,
:slug
]
if
index_exists?
:environments
,
[
:project_id
,
:slug
]
end
end
db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb
View file @
67729cec
...
...
@@ -49,6 +49,16 @@ class AddForeignKeysToTimelogs < ActiveRecord::Migration
Timelog
.
where
(
'issue_id IS NOT NULL'
).
update_all
(
"trackable_id = issue_id, trackable_type = 'Issue'"
)
Timelog
.
where
(
'merge_request_id IS NOT NULL'
).
update_all
(
"trackable_id = merge_request_id, trackable_type = 'MergeRequest'"
)
constraint
=
if
Gitlab
::
Database
.
postgresql?
'CONSTRAINT'
else
'FOREIGN KEY'
end
execute
"ALTER TABLE timelogs DROP
#{
constraint
}
fk_timelogs_issues_issue_id"
execute
"ALTER TABLE timelogs DROP
#{
constraint
}
fk_timelogs_merge_requests_merge_request_id"
remove_columns
:timelogs
,
:issue_id
,
:merge_request_id
end
end
db/migrate/20170216141440_drop_index_for_builds_project_status.rb
View file @
67729cec
...
...
@@ -3,6 +3,6 @@ class DropIndexForBuildsProjectStatus < ActiveRecord::Migration
DOWNTIME
=
false
def
change
remove_index
(
:ci_commits
,
[
:gl_project_id
,
:status
])
remove_index
(
:ci_commits
,
column:
[
:gl_project_id
,
:status
])
end
end
db/post_migrate/20170206101007_remove_trackable_columns_from_timelogs.rb
View file @
67729cec
...
...
@@ -18,6 +18,7 @@ class RemoveTrackableColumnsFromTimelogs < ActiveRecord::Migration
# disable_ddl_transaction!
def
change
remove_columns
:timelogs
,
:trackable_id
,
:trackable_type
remove_column
:timelogs
,
:trackable_id
,
:integer
remove_column
:timelogs
,
:trackable_type
,
:string
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