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
8e071f28
Commit
8e071f28
authored
Jun 06, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve indexes and refs in pipeline stages migrations
parent
cc1e2a2b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
43 deletions
+31
-43
db/migrate/20170525132202_create_pipeline_stages.rb
db/migrate/20170525132202_create_pipeline_stages.rb
+12
-1
db/migrate/20170526185602_add_stage_id_to_ci_builds.rb
db/migrate/20170526185602_add_stage_id_to_ci_builds.rb
+13
-1
db/post_migrate/20170526185842_migrate_pipeline_stages.rb
db/post_migrate/20170526185842_migrate_pipeline_stages.rb
+0
-4
db/post_migrate/20170526190708_create_foreign_keys_for_pipeline_stages.rb
...20170526190708_create_foreign_keys_for_pipeline_stages.rb
+0
-35
db/schema.rb
db/schema.rb
+6
-2
No files found.
db/migrate/20170525132202_create_pipeline_stages.rb
View file @
8e071f28
...
...
@@ -3,12 +3,23 @@ class CreatePipelineStages < ActiveRecord::Migration
DOWNTIME
=
false
def
change
disable_ddl_transaction!
def
up
create_table
:ci_stages
do
|
t
|
t
.
integer
:project_id
t
.
integer
:pipeline_id
t
.
timestamps
null:
true
t
.
string
:name
end
add_concurrent_foreign_key
:ci_stages
,
:projects
,
column: :project_id
,
on_delete: :cascade
add_concurrent_foreign_key
:ci_stages
,
:ci_pipelines
,
column: :pipeline_id
,
on_delete: :cascade
add_concurrent_index
:ci_stages
,
:project_id
add_concurrent_index
:ci_stages
,
:pipeline_id
end
def
down
drop_table
:ci_stages
end
end
db/migrate/20170526185602_add_stage_id_to_ci_builds.rb
View file @
8e071f28
...
...
@@ -3,7 +3,19 @@ class AddStageIdToCiBuilds < ActiveRecord::Migration
DOWNTIME
=
false
def
change
disable_ddl_transaction!
def
up
add_column
:ci_builds
,
:stage_id
,
:integer
add_concurrent_foreign_key
:ci_builds
,
:ci_stages
,
column: :stage_id
,
on_delete: :cascade
add_concurrent_index
:ci_builds
,
:stage_id
end
def
down
remove_concurrent_index
:ci_builds
,
:stage_id
remove_foreign_key
:ci_builds
,
column: :stage_id
remove_column
:ci_builds
,
:stage_id
,
:integer
end
end
db/post_migrate/20170526185842_migrate_pipeline_stages.rb
View file @
8e071f28
...
...
@@ -16,8 +16,4 @@ class MigratePipelineStages < ActiveRecord::Migration
ORDER BY MAX(stage_idx)
SQL
end
def
down
execute
(
'TRUNCATE TABLE ci_stages'
)
end
end
db/post_migrate/20170526190708_create_foreign_keys_for_pipeline_stages.rb
deleted
100644 → 0
View file @
cc1e2a2b
class
CreateForeignKeysForPipelineStages
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
disable_statement_timeout
execute
<<~
SQL
DELETE FROM ci_stages
WHERE NOT EXISTS (
SELECT true FROM projects
WHERE projects.id = ci_stages.project_id
)
SQL
execute
<<~
SQL
DELETE FROM ci_builds
WHERE NOT EXISTS (
SELECT true FROM ci_stages
WHERE ci_stages.id = ci_builds.stage_id
)
SQL
add_concurrent_foreign_key
:ci_stages
,
:projects
,
column: :project_id
,
on_delete: :cascade
add_concurrent_foreign_key
:ci_builds
,
:ci_stages
,
column: :stage_id
,
on_delete: :cascade
end
def
down
remove_foreign_key
:ci_stages
,
column: :project_id
remove_foreign_key
:ci_builds
,
column: :stage_id
end
end
db/schema.rb
View file @
8e071f28
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201705261
90708
)
do
ActiveRecord
::
Schema
.
define
(
version:
201705261
85921
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -243,6 +243,7 @@ ActiveRecord::Schema.define(version: 20170526190708) do
add_index
"ci_builds"
,
[
"commit_id"
,
"type"
,
"ref"
],
name:
"index_ci_builds_on_commit_id_and_type_and_ref"
,
using: :btree
add_index
"ci_builds"
,
[
"project_id"
],
name:
"index_ci_builds_on_project_id"
,
using: :btree
add_index
"ci_builds"
,
[
"runner_id"
],
name:
"index_ci_builds_on_runner_id"
,
using: :btree
add_index
"ci_builds"
,
[
"stage_id"
],
name:
"index_ci_builds_on_stage_id"
,
using: :btree
add_index
"ci_builds"
,
[
"status"
,
"type"
,
"runner_id"
],
name:
"index_ci_builds_on_status_and_type_and_runner_id"
,
using: :btree
add_index
"ci_builds"
,
[
"status"
],
name:
"index_ci_builds_on_status"
,
using: :btree
add_index
"ci_builds"
,
[
"token"
],
name:
"index_ci_builds_on_token"
,
unique:
true
,
using: :btree
...
...
@@ -330,12 +331,14 @@ ActiveRecord::Schema.define(version: 20170526190708) do
create_table
"ci_stages"
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
t
.
integer
"pipeline_id"
t
.
string
"name"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
string
"name"
end
add_index
"ci_stages"
,
[
"pipeline_id"
,
"name"
],
name:
"index_ci_stages_on_pipeline_id_and_name"
,
using: :btree
add_index
"ci_stages"
,
[
"pipeline_id"
],
name:
"index_ci_stages_on_pipeline_id"
,
using: :btree
add_index
"ci_stages"
,
[
"project_id"
],
name:
"index_ci_stages_on_project_id"
,
using: :btree
create_table
"ci_trigger_requests"
,
force: :cascade
do
|
t
|
t
.
integer
"trigger_id"
,
null:
false
...
...
@@ -1497,6 +1500,7 @@ ActiveRecord::Schema.define(version: 20170526190708) do
add_foreign_key
"ci_pipeline_schedules"
,
"users"
,
column:
"owner_id"
,
name:
"fk_9ea99f58d2"
,
on_delete: :nullify
add_foreign_key
"ci_pipelines"
,
"ci_pipeline_schedules"
,
column:
"pipeline_schedule_id"
,
name:
"fk_3d34ab2e06"
,
on_delete: :nullify
add_foreign_key
"ci_pipelines"
,
"ci_pipelines"
,
column:
"auto_canceled_by_id"
,
name:
"fk_262d4c2d19"
,
on_delete: :nullify
add_foreign_key
"ci_stages"
,
"ci_pipelines"
,
column:
"pipeline_id"
,
name:
"fk_fb57e6cc56"
,
on_delete: :cascade
add_foreign_key
"ci_stages"
,
"projects"
,
name:
"fk_2360681d1d"
,
on_delete: :cascade
add_foreign_key
"ci_trigger_requests"
,
"ci_triggers"
,
column:
"trigger_id"
,
name:
"fk_b8ec8b7245"
,
on_delete: :cascade
add_foreign_key
"ci_triggers"
,
"users"
,
column:
"owner_id"
,
name:
"fk_e8e10d1964"
,
on_delete: :cascade
...
...
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