summaryrefslogtreecommitdiff
path: root/db/post_migrate
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-21 10:32:45 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-21 13:18:38 +0200
commit6b9608e13e20fe579b861b911880603a372f2f27 (patch)
treeb78f460139e23a43c41e91a443eb70b6834704da /db/post_migrate
parent4b0b2f1525be5feac0ae0953eb573ff24cc7b9c5 (diff)
downloadgitlab-ce-6b9608e13e20fe579b861b911880603a372f2f27.tar.gz
Fix build stages reference migration
Diffstat (limited to 'db/post_migrate')
-rw-r--r--db/post_migrate/20170526185901_remove_stage_id_index_from_builds.rb17
-rw-r--r--db/post_migrate/20170526185921_migrate_build_stage_reference.rb2
-rw-r--r--db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb19
3 files changed, 38 insertions, 0 deletions
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..a2c0b0c651b
--- /dev/null
+++ b/db/post_migrate/20170526185901_remove_stage_id_index_from_builds.rb
@@ -0,0 +1,17 @@
+class RemoveStageIdIndexFromBuilds < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ if index_exists?(:ci_builds, :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..d2e7fc207f0 100644
--- a/db/post_migrate/20170526185921_migrate_build_stage_reference.rb
+++ b/db/post_migrate/20170526185921_migrate_build_stage_reference.rb
@@ -3,6 +3,8 @@ class MigrateBuildStageReference < ActiveRecord::Migration
DOWNTIME = false
+ disable_ddl_transaction!
+
def up
disable_statement_timeout
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..acbe16812d2
--- /dev/null
+++ b/db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb
@@ -0,0 +1,19 @@
+class AddStageIdIndexToBuilds < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ unless index_exists?(:ci_builds, :stage_id)
+ add_concurrent_index(:ci_builds, :stage_id)
+ end
+ end
+
+ def down
+ if index_exists?(:ci_builds, :stage_id)
+ remove_concurrent_index(:ci_builds, :stage_id)
+ end
+ end
+end