diff options
author | Clement Ho <clemmakesapps@gmail.com> | 2017-06-22 08:57:11 +0300 |
---|---|---|
committer | Clement Ho <clemmakesapps@gmail.com> | 2017-06-22 08:57:11 +0300 |
commit | b3edcfeb51d7930ad0330e401f2ef5f27ee9671c (patch) | |
tree | a8d34dec7a3923f9ef807373980d62c2247ca394 /db | |
parent | 31573d98f9e34a4fec6c41e0e8c8f3151e8837b5 (diff) | |
parent | 261e4fe8d8e6c01d0278a9e3770fe78d75336a07 (diff) |
Merge branch '9-3-stable-rc7' into '9-3-stable'
Prepare 9.3 RC7
See merge request !12348
Diffstat (limited to 'db')
8 files changed, 94 insertions, 23 deletions
diff --git a/db/migrate/20170526185602_add_stage_id_to_ci_builds.rb b/db/migrate/20170526185602_add_stage_id_to_ci_builds.rb index d5675d5828b..d27cba76d81 100644 --- a/db/migrate/20170526185602_add_stage_id_to_ci_builds.rb +++ b/db/migrate/20170526185602_add_stage_id_to_ci_builds.rb @@ -3,19 +3,11 @@ class AddStageIdToCiBuilds < ActiveRecord::Migration DOWNTIME = false - 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_foreign_key :ci_builds, column: :stage_id - remove_concurrent_index :ci_builds, :stage_id - remove_column :ci_builds, :stage_id, :integer end end diff --git a/db/migrate/20170619144837_add_index_for_head_pipeline_merge_request.rb b/db/migrate/20170619144837_add_index_for_head_pipeline_merge_request.rb new file mode 100644 index 00000000000..02863bee082 --- /dev/null +++ b/db/migrate/20170619144837_add_index_for_head_pipeline_merge_request.rb @@ -0,0 +1,15 @@ +class AddIndexForHeadPipelineMergeRequest < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :merge_requests, :head_pipeline_id + end + + def down + remove_concurrent_index :merge_requests, :head_pipeline_id if index_exists?(:merge_requests, :head_pipeline_id) + end +end diff --git a/db/post_migrate/20170502070007_enable_auto_cancel_pending_pipelines_for_all.rb b/db/post_migrate/20170502070007_enable_auto_cancel_pending_pipelines_for_all.rb index 3c13a3d2518..765daa0a347 100644 --- a/db/post_migrate/20170502070007_enable_auto_cancel_pending_pipelines_for_all.rb +++ b/db/post_migrate/20170502070007_enable_auto_cancel_pending_pipelines_for_all.rb @@ -7,6 +7,8 @@ class EnableAutoCancelPendingPipelinesForAll < ActiveRecord::Migration DOWNTIME = false def up + disable_statement_timeout + update_column_in_batches(:projects, :auto_cancel_pending_pipelines, 1) end diff --git a/db/post_migrate/20170526185901_remove_stage_id_index_from_builds.rb b/db/post_migrate/20170526185901_remove_stage_id_index_from_builds.rb new file mode 100644 index 00000000000..3879cf9133b --- /dev/null +++ b/db/post_migrate/20170526185901_remove_stage_id_index_from_builds.rb @@ -0,0 +1,18 @@ +class RemoveStageIdIndexFromBuilds < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + if index_exists?(:ci_builds, :stage_id) + remove_foreign_key(:ci_builds, column: :stage_id) + remove_concurrent_index(:ci_builds, :stage_id) + end + end + + def down + # noop + end +end diff --git a/db/post_migrate/20170526185921_migrate_build_stage_reference.rb b/db/post_migrate/20170526185921_migrate_build_stage_reference.rb index 797e106cae4..98c32d8284c 100644 --- a/db/post_migrate/20170526185921_migrate_build_stage_reference.rb +++ b/db/post_migrate/20170526185921_migrate_build_stage_reference.rb @@ -3,23 +3,17 @@ class MigrateBuildStageReference < ActiveRecord::Migration DOWNTIME = false - def up - disable_statement_timeout - - stage_id = Arel.sql <<-SQL.strip_heredoc - (SELECT id FROM ci_stages - WHERE ci_stages.pipeline_id = ci_builds.commit_id - AND ci_stages.name = ci_builds.stage) - SQL + ## + # This is an empty migration, content has been moved to a new one: + # post migrate 20170526190000 MigrateBuildStageReferenceAgain + # + # See gitlab-org/gitlab-ce!12337 for more details. - update_column_in_batches(:ci_builds, :stage_id, stage_id) do |table, query| - query.where(table[:stage_id].eq(nil)) - end + def up + # noop end def down - disable_statement_timeout - - update_column_in_batches(:ci_builds, :stage_id, nil) + # noop end end diff --git a/db/post_migrate/20170526190000_migrate_build_stage_reference_again.rb b/db/post_migrate/20170526190000_migrate_build_stage_reference_again.rb new file mode 100644 index 00000000000..97cb242415d --- /dev/null +++ b/db/post_migrate/20170526190000_migrate_build_stage_reference_again.rb @@ -0,0 +1,27 @@ +class MigrateBuildStageReferenceAgain < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + disable_statement_timeout + + stage_id = Arel.sql <<-SQL.strip_heredoc + (SELECT id FROM ci_stages + WHERE ci_stages.pipeline_id = ci_builds.commit_id + AND ci_stages.name = ci_builds.stage) + SQL + + update_column_in_batches(:ci_builds, :stage_id, stage_id) do |table, query| + query.where(table[:stage_id].eq(nil)) + end + end + + def down + disable_statement_timeout + + update_column_in_batches(:ci_builds, :stage_id, nil) + end +end diff --git a/db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb b/db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb new file mode 100644 index 00000000000..7d6609b18bf --- /dev/null +++ b/db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb @@ -0,0 +1,21 @@ +class AddStageIdIndexToBuilds < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + unless index_exists?(:ci_builds, :stage_id) + add_concurrent_foreign_key(:ci_builds, :ci_stages, column: :stage_id, on_delete: :cascade) + add_concurrent_index(:ci_builds, :stage_id) + end + end + + def down + if index_exists?(:ci_builds, :stage_id) + remove_foreign_key(:ci_builds, column: :stage_id) + remove_concurrent_index(:ci_builds, :stage_id) + end + end +end diff --git a/db/schema.rb b/db/schema.rb index b93630a410d..6c7971a847e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,8 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170606202615) do +ActiveRecord::Schema.define(version: 20170621102400) do + # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" enable_extension "pg_trgm" @@ -760,6 +761,7 @@ ActiveRecord::Schema.define(version: 20170606202615) do add_index "merge_requests", ["created_at"], name: "index_merge_requests_on_created_at", using: :btree add_index "merge_requests", ["deleted_at"], name: "index_merge_requests_on_deleted_at", using: :btree add_index "merge_requests", ["description"], name: "index_merge_requests_on_description_trigram", using: :gin, opclasses: {"description"=>"gin_trgm_ops"} + add_index "merge_requests", ["head_pipeline_id"], name: "index_merge_requests_on_head_pipeline_id", using: :btree add_index "merge_requests", ["milestone_id"], name: "index_merge_requests_on_milestone_id", using: :btree add_index "merge_requests", ["source_branch"], name: "index_merge_requests_on_source_branch", using: :btree add_index "merge_requests", ["source_project_id"], name: "index_merge_requests_on_source_project_id", using: :btree |