summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-05-26 20:50:43 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-05-26 20:50:43 +0200
commit56681cf7954eeeba227b73cfeb163eb4e51dc96f (patch)
tree52927490e5fd21c28d632724b5d1e6d1a5784143 /db
parent918ababba6fce694c61d54bb2ff6983a886f696a (diff)
downloadgitlab-ce-56681cf7954eeeba227b73cfeb163eb4e51dc96f.tar.gz
Use a separate migration to create pipeline stages index
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20170526101042_migrate_pipeline_stages.rb10
-rw-r--r--db/post_migrate/20170526180645_create_index_in_pipeline_stages.rb15
2 files changed, 15 insertions, 10 deletions
diff --git a/db/post_migrate/20170526101042_migrate_pipeline_stages.rb b/db/post_migrate/20170526101042_migrate_pipeline_stages.rb
index 12ad0db3a60..9ef351dff93 100644
--- a/db/post_migrate/20170526101042_migrate_pipeline_stages.rb
+++ b/db/post_migrate/20170526101042_migrate_pipeline_stages.rb
@@ -16,8 +16,6 @@ class MigratePipelineStages < ActiveRecord::Migration
ORDER BY stage_idx
SQL
- add_concurrent_index(:ci_stages, [:pipeline_id, :name])
-
add_column(:ci_builds, :stage_id, :integer)
stage_id = Arel.sql('(SELECT id FROM ci_stages ' \
@@ -31,13 +29,5 @@ class MigratePipelineStages < ActiveRecord::Migration
def down
execute('TRUNCATE TABLE ci_stages')
-
- if column_exists?(:ci_builds, :stage_id)
- remove_column(:ci_builds, :stage_id)
- end
-
- if index_exists?(:ci_stages, [:pipeline_id, :name])
- remove_index(:ci_stages, [:pipeline_id, :name])
- end
end
end
diff --git a/db/post_migrate/20170526180645_create_index_in_pipeline_stages.rb b/db/post_migrate/20170526180645_create_index_in_pipeline_stages.rb
new file mode 100644
index 00000000000..d049f87578a
--- /dev/null
+++ b/db/post_migrate/20170526180645_create_index_in_pipeline_stages.rb
@@ -0,0 +1,15 @@
+class CreateIndexInPipelineStages < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(:ci_stages, [:pipeline_id, :name])
+ end
+
+ def down
+ remove_index(:ci_stages, [:pipeline_id, :name])
+ end
+end