summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-15 15:49:40 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-15 15:49:40 +0000
commitb04b1e12c5847f7d366e08af47115d985b73e185 (patch)
tree5077e33eedbf1e99b9ef9b87395f9acce844b234 /db
parenta5b9fb9abc2b83304f45392642801b28f52b3f48 (diff)
downloadgitlab-ce-b04b1e12c5847f7d366e08af47115d985b73e185.tar.gz
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20191229140154_drop_index_ci_pipelines_on_project_id.rb7
-rw-r--r--db/post_migrate/20200511162057_add_missing_instance_to_servicess.rb30
-rw-r--r--db/post_migrate/20200511162115_add_missing_index_to_service_unique_instance_per_type.rb25
-rw-r--r--db/structure.sql2
4 files changed, 62 insertions, 2 deletions
diff --git a/db/migrate/20191229140154_drop_index_ci_pipelines_on_project_id.rb b/db/migrate/20191229140154_drop_index_ci_pipelines_on_project_id.rb
index dbfe3758cda..9e78457b007 100644
--- a/db/migrate/20191229140154_drop_index_ci_pipelines_on_project_id.rb
+++ b/db/migrate/20191229140154_drop_index_ci_pipelines_on_project_id.rb
@@ -8,10 +8,13 @@ class DropIndexCiPipelinesOnProjectId < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
def up
- remove_concurrent_index :ci_pipelines, :project_id
+ remove_concurrent_index_by_name :ci_pipelines, 'index_ci_pipelines_on_project_id'
+
+ # extra (duplicate) index that already existed on some installs
+ remove_concurrent_index_by_name :ci_pipelines, 'ci_pipelines_project_id_idx'
end
def down
- add_concurrent_index :ci_pipelines, :project_id
+ add_concurrent_index :ci_pipelines, :project_id, name: 'index_ci_pipelines_on_project_id'
end
end
diff --git a/db/post_migrate/20200511162057_add_missing_instance_to_servicess.rb b/db/post_migrate/20200511162057_add_missing_instance_to_servicess.rb
new file mode 100644
index 00000000000..efaef085e8c
--- /dev/null
+++ b/db/post_migrate/20200511162057_add_missing_instance_to_servicess.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+class AddMissingInstanceToServicess < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ # This is a corrective migration to keep the instance column.
+ # Upgrade from 12.7 to 12.9 removes the instance column as it was first added
+ # in the normal migration and then removed in the post migration.
+ #
+ # 12.8 removed the instance column in a post deployment migration https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24885
+ # 12.9 added the instance column in a normal migration https://gitlab.com/gitlab-org/gitlab/-/merge_requests/25714
+ #
+ # rubocop:disable Migration/AddColumnWithDefault
+ # rubocop:disable Migration/UpdateLargeTable
+ def up
+ unless column_exists?(:services, :instance)
+ add_column_with_default(:services, :instance, :boolean, default: false)
+ end
+ end
+ # rubocop:enable Migration/AddColumnWithDefault
+ # rubocop:enable Migration/UpdateLargeTable
+
+ def down
+ # Does not apply
+ end
+end
diff --git a/db/post_migrate/20200511162115_add_missing_index_to_service_unique_instance_per_type.rb b/db/post_migrate/20200511162115_add_missing_index_to_service_unique_instance_per_type.rb
new file mode 100644
index 00000000000..c9e0193f5d2
--- /dev/null
+++ b/db/post_migrate/20200511162115_add_missing_index_to_service_unique_instance_per_type.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class AddMissingIndexToServiceUniqueInstancePerType < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ # This is a corrective migration to keep the index on instance column.
+ # Upgrade from 12.7 to 12.9 removes the instance column as it was first added
+ # in the normal migration and then removed in the post migration.
+ #
+ # 12.8 removed the instance column in a post deployment migration https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24885
+ # 12.9 added the instance column in a normal migration https://gitlab.com/gitlab-org/gitlab/-/merge_requests/25714
+ def up
+ unless index_exists_by_name?(:services, 'index_services_on_type_and_instance')
+ add_concurrent_index(:services, [:type, :instance], unique: true, where: 'instance IS TRUE')
+ end
+ end
+
+ def down
+ # Does not apply
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index 3fec80b1aba..1f0f401165e 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -13214,5 +13214,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200416111111
20200416120128
20200416120354
+20200511162057
+20200511162115
\.