diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /db/migrate/20200908033805_add_dast_site_validation_id_to_dast_site.rb | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'db/migrate/20200908033805_add_dast_site_validation_id_to_dast_site.rb')
-rw-r--r-- | db/migrate/20200908033805_add_dast_site_validation_id_to_dast_site.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/db/migrate/20200908033805_add_dast_site_validation_id_to_dast_site.rb b/db/migrate/20200908033805_add_dast_site_validation_id_to_dast_site.rb new file mode 100644 index 00000000000..3ac86fb1d9e --- /dev/null +++ b/db/migrate/20200908033805_add_dast_site_validation_id_to_dast_site.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +class AddDastSiteValidationIdToDastSite < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + TABLE_NAME = :dast_sites + RELATION_NAME = :dast_site_validations + FK_NAME = :dast_site_validation_id + INDEX_NAME = "index_dast_sites_on_#{FK_NAME}" + + disable_ddl_transaction! + + def up + unless column_exists?(TABLE_NAME, FK_NAME) + with_lock_retries do + add_column TABLE_NAME, FK_NAME, :bigint + end + end + + add_concurrent_index TABLE_NAME, FK_NAME, name: INDEX_NAME + add_concurrent_foreign_key TABLE_NAME, RELATION_NAME, column: FK_NAME, on_delete: :nullify + end + + def down + remove_foreign_key_if_exists TABLE_NAME, RELATION_NAME + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + + with_lock_retries do + remove_column TABLE_NAME, FK_NAME + end + end +end |