summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-02-20 13:53:54 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-02-20 14:00:03 +0100
commit2f3f9a6bb0b4777146eb1ccc33ba14910cbd4746 (patch)
tree896fcd26f27efd0b630b981aa6dcc22ba2354726 /db
parent2d027056f9c56ad733bcccf54c3b7cf8c7cb95bf (diff)
downloadgitlab-ce-2f3f9a6bb0b4777146eb1ccc33ba14910cbd4746.tar.gz
Separate adding and removing index from stages migration
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20180212101828_add_tmp_partial_null_index_to_builds.rb14
-rw-r--r--db/post_migrate/20180212101928_schedule_build_stage_migration.rb5
-rw-r--r--db/post_migrate/20180212102028_remove_tmp_partial_null_index_from_builds.rb14
-rw-r--r--db/schema.rb2
4 files changed, 29 insertions, 6 deletions
diff --git a/db/post_migrate/20180212101828_add_tmp_partial_null_index_to_builds.rb b/db/post_migrate/20180212101828_add_tmp_partial_null_index_to_builds.rb
new file mode 100644
index 00000000000..df62ddf36c7
--- /dev/null
+++ b/db/post_migrate/20180212101828_add_tmp_partial_null_index_to_builds.rb
@@ -0,0 +1,14 @@
+class AddTmpPartialNullIndexToBuilds < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(:ci_builds, :stage_id, where: 'stage_id IS NULL',
+ name: 'tmp_stage_id_partial_null_index')
+ end
+
+ def down
+ remove_concurrent_index_by_name(:ci_builds, 'tmp_stage_id_partial_null_index')
+ end
+end
diff --git a/db/post_migrate/20180212101928_schedule_build_stage_migration.rb b/db/post_migrate/20180212101928_schedule_build_stage_migration.rb
index f42a09f2223..df15b2cd9d4 100644
--- a/db/post_migrate/20180212101928_schedule_build_stage_migration.rb
+++ b/db/post_migrate/20180212101928_schedule_build_stage_migration.rb
@@ -15,17 +15,12 @@ class ScheduleBuildStageMigration < ActiveRecord::Migration
def up
disable_statement_timeout
- add_concurrent_index(:ci_builds, :stage_id, where: 'stage_id IS NULL',
- name: 'tmp_stage_id_partial_null_index')
-
Build.where('stage_id IS NULL').tap do |relation|
queue_background_migration_jobs_by_range_at_intervals(relation,
MIGRATION,
5.minutes,
batch_size: BATCH_SIZE)
end
-
- remove_concurrent_index_by_name(:ci_builds, 'tmp_stage_id_partial_null_index')
end
def down
diff --git a/db/post_migrate/20180212102028_remove_tmp_partial_null_index_from_builds.rb b/db/post_migrate/20180212102028_remove_tmp_partial_null_index_from_builds.rb
new file mode 100644
index 00000000000..139097399a6
--- /dev/null
+++ b/db/post_migrate/20180212102028_remove_tmp_partial_null_index_from_builds.rb
@@ -0,0 +1,14 @@
+class RemoveTmpPartialNullIndexFromBuilds < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index_by_name(:ci_builds, 'tmp_stage_id_partial_null_index')
+ end
+
+ def down
+ add_concurrent_index(:ci_builds, :stage_id, where: 'stage_id IS NULL',
+ name: 'tmp_stage_id_partial_null_index')
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index b57094818e2..1f41b97041e 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20180212101928) do
+ActiveRecord::Schema.define(version: 20180212102028) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"