diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-17 13:07:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-17 13:07:47 +0300 |
commit | d670c3006e6e44901bce0d53cc4768d1d80ffa92 (patch) | |
tree | 8f65743c232e5b76850c4cc264ba15e1185815ff /db/migrate | |
parent | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-ee
Diffstat (limited to 'db/migrate')
5 files changed, 93 insertions, 0 deletions
diff --git a/db/migrate/20210608103230_add_issue_id_to_test_report.rb b/db/migrate/20210608103230_add_issue_id_to_test_report.rb new file mode 100644 index 00000000000..f4e723d0af8 --- /dev/null +++ b/db/migrate/20210608103230_add_issue_id_to_test_report.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddIssueIdToTestReport < ActiveRecord::Migration[6.1] + include Gitlab::Database::MigrationHelpers + + def up + with_lock_retries do + add_column :requirements_management_test_reports, :issue_id, :bigint, null: true + end + end + + def down + with_lock_retries do + remove_column :requirements_management_test_reports, :issue_id + end + end +end diff --git a/db/migrate/20210608103235_add_issue_index_to_test_report.rb b/db/migrate/20210608103235_add_issue_index_to_test_report.rb new file mode 100644 index 00000000000..41f1970b2a9 --- /dev/null +++ b/db/migrate/20210608103235_add_issue_index_to_test_report.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddIssueIndexToTestReport < ActiveRecord::Migration[6.1] + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + INDEX_NAME = 'index_requirements_management_test_reports_on_issue_id' + + def up + add_concurrent_index :requirements_management_test_reports, :issue_id, name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :requirements_management_test_reports, INDEX_NAME + end +end diff --git a/db/migrate/20210608110752_change_column_null_test_report_requirement.rb b/db/migrate/20210608110752_change_column_null_test_report_requirement.rb new file mode 100644 index 00000000000..44a614a34ce --- /dev/null +++ b/db/migrate/20210608110752_change_column_null_test_report_requirement.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class ChangeColumnNullTestReportRequirement < ActiveRecord::Migration[6.1] + include Gitlab::Database::MigrationHelpers + + TARGET_TABLE = :requirements_management_test_reports + + def up + with_lock_retries do + change_column_null TARGET_TABLE, :requirement_id, true + end + end + + def down + # no-op as it's difficult to revert + end +end diff --git a/db/migrate/20210608110760_add_requirement_test_reports_foreign_key.rb b/db/migrate/20210608110760_add_requirement_test_reports_foreign_key.rb new file mode 100644 index 00000000000..e256bce6ae0 --- /dev/null +++ b/db/migrate/20210608110760_add_requirement_test_reports_foreign_key.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class AddRequirementTestReportsForeignKey < ActiveRecord::Migration[6.1] + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + TARGET_TABLE = :requirements_management_test_reports + CONSTRAINT_NAME = 'requirements_test_reports_requirement_id_xor_issue_id' + + def up + add_concurrent_foreign_key TARGET_TABLE, :issues, column: :issue_id + + add_check_constraint(TARGET_TABLE, 'num_nonnulls(requirement_id, issue_id) = 1', CONSTRAINT_NAME) + end + + def down + remove_check_constraint TARGET_TABLE, CONSTRAINT_NAME + + with_lock_retries do + remove_foreign_key_if_exists(TARGET_TABLE, column: :issue_id) + end + end +end diff --git a/db/migrate/20210614143954_add_unique_index_for_helm_packages.rb b/db/migrate/20210614143954_add_unique_index_for_helm_packages.rb new file mode 100644 index 00000000000..e6b7ba7616d --- /dev/null +++ b/db/migrate/20210614143954_add_unique_index_for_helm_packages.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddUniqueIndexForHelmPackages < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + INDEX_NAME = 'index_packages_on_project_id_name_version_unique_when_helm' + PACKAGE_TYPE_HELM = 11 + + disable_ddl_transaction! + + def up + add_concurrent_index :packages_packages, [:project_id, :name, :version], unique: true, where: "package_type = #{PACKAGE_TYPE_HELM}", name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :packages_packages, INDEX_NAME + end +end |