diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-06-06 14:10:50 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-06-06 14:10:50 +0200 |
commit | 8e071f28097b2c55b9e8d1b3a7ced4cdd04ef44d (patch) | |
tree | dea02b489c41af11a444717a416af79b83a8a77d /db/migrate | |
parent | cc1e2a2bef324fe5869393e04be2feed22576667 (diff) | |
download | gitlab-ce-8e071f28097b2c55b9e8d1b3a7ced4cdd04ef44d.tar.gz |
Improve indexes and refs in pipeline stages migrations
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20170525132202_create_pipeline_stages.rb | 13 | ||||
-rw-r--r-- | db/migrate/20170526185602_add_stage_id_to_ci_builds.rb | 14 |
2 files changed, 25 insertions, 2 deletions
diff --git a/db/migrate/20170525132202_create_pipeline_stages.rb b/db/migrate/20170525132202_create_pipeline_stages.rb index 634f2c1156e..25656f2a2c2 100644 --- a/db/migrate/20170525132202_create_pipeline_stages.rb +++ b/db/migrate/20170525132202_create_pipeline_stages.rb @@ -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 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 0788f15f7c5..e8009e74ea5 100644 --- a/db/migrate/20170526185602_add_stage_id_to_ci_builds.rb +++ b/db/migrate/20170526185602_add_stage_id_to_ci_builds.rb @@ -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 |