Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
462b603802
commit
7b2dc9fe33
|
|
@ -306,6 +306,11 @@ qa-frontend-node:latest:
|
|||
- .qa-frontend-node
|
||||
- .frontend:rules:qa-frontend-node-latest
|
||||
image: ${GITLAB_DEPENDENCY_PROXY}node:latest
|
||||
# This is a workaround for https://github.com/webpack/webpack/issues/14532 until
|
||||
# we can upgrade to Webpack 5 and switch to SHA256: https://gitlab.com/gitlab-org/gitlab/-/issues/350120
|
||||
script:
|
||||
- *yarn-install
|
||||
- run_timed_command "retry yarn run webpack-prod-node-latest"
|
||||
|
||||
webpack-dev-server:
|
||||
extends:
|
||||
|
|
|
|||
|
|
@ -346,7 +346,7 @@ rspec fast_spec_helper minimal:
|
|||
db:rollback:
|
||||
extends: .db-job-base
|
||||
script:
|
||||
- scripts/db_tasks db:migrate VERSION=20181228175414
|
||||
- scripts/db_tasks db:migrate VERSION=20210301200959
|
||||
- scripts/db_tasks db:migrate SKIP_SCHEMA_VERSION_CHECK=true
|
||||
|
||||
db:rollback decomposed:
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ Style/OpenStructUse:
|
|||
- spec/lib/gitlab/quick_actions/command_definition_spec.rb
|
||||
- spec/models/design_management/design_action_spec.rb
|
||||
- spec/models/design_management/design_at_version_spec.rb
|
||||
- spec/models/user_spec.rb
|
||||
- spec/presenters/packages/nuget/search_results_presenter_spec.rb
|
||||
- spec/services/packages/nuget/metadata_extraction_service_spec.rb
|
||||
- spec/services/projects/import_service_spec.rb
|
||||
- spec/services/system_note_service_spec.rb
|
||||
|
|
|
|||
|
|
@ -1,53 +0,0 @@
|
|||
import $ from 'jquery';
|
||||
|
||||
const MODAL_SELECTOR = '#modal-delete-branch';
|
||||
|
||||
class DeleteModal {
|
||||
constructor() {
|
||||
this.$modal = $(MODAL_SELECTOR);
|
||||
this.$toggleBtns = $(`[data-target="${MODAL_SELECTOR}"]`);
|
||||
this.$branchName = $('.js-branch-name', this.$modal);
|
||||
this.$confirmInput = $('.js-delete-branch-input', this.$modal);
|
||||
this.$deleteBtn = $('.js-delete-branch', this.$modal);
|
||||
this.$notMerged = $('.js-not-merged', this.$modal);
|
||||
this.bindEvents();
|
||||
}
|
||||
|
||||
bindEvents() {
|
||||
this.$toggleBtns.on('click', this.setModalData.bind(this));
|
||||
this.$confirmInput.on('input', this.setDeleteDisabled.bind(this));
|
||||
this.$deleteBtn.on('click', this.setDisableDeleteButton.bind(this));
|
||||
}
|
||||
|
||||
setModalData(e) {
|
||||
const branchData = e.currentTarget.dataset;
|
||||
this.branchName = branchData.branchName || '';
|
||||
this.deletePath = branchData.deletePath || '';
|
||||
this.isMerged = Boolean(branchData.isMerged);
|
||||
this.updateModal();
|
||||
}
|
||||
|
||||
setDeleteDisabled(e) {
|
||||
this.$deleteBtn.attr('disabled', e.currentTarget.value !== this.branchName);
|
||||
}
|
||||
|
||||
setDisableDeleteButton(e) {
|
||||
if (this.$deleteBtn.is('[disabled]')) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
updateModal() {
|
||||
this.$branchName.text(this.branchName);
|
||||
this.$confirmInput.val('');
|
||||
this.$deleteBtn.attr('href', this.deletePath);
|
||||
this.$deleteBtn.attr('disabled', true);
|
||||
this.$notMerged.toggleClass('hidden', this.isMerged);
|
||||
}
|
||||
}
|
||||
|
||||
export default DeleteModal;
|
||||
|
|
@ -122,12 +122,12 @@ export default {
|
|||
</p>
|
||||
|
||||
<gl-tabs sync-active-tab-with-query-params lazy>
|
||||
<slot name="ee-security-tab" :cluster-agent-id="clusterAgent.id"></slot>
|
||||
|
||||
<gl-tab :title="$options.i18n.activity" query-param-value="activity">
|
||||
<activity-events :agent-name="agentName" :project-path="projectPath" />
|
||||
</gl-tab>
|
||||
|
||||
<slot name="ee-security-tab" :cluster-agent-id="clusterAgent.id"></slot>
|
||||
|
||||
<gl-tab query-param-value="tokens">
|
||||
<template #title>
|
||||
<span data-testid="cluster-agent-token-count">
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
import initDeprecatedRemoveRowBehavior from '~/behaviors/deprecated_remove_row_behavior';
|
||||
import AjaxLoadingSpinner from '~/branches/ajax_loading_spinner';
|
||||
import BranchSortDropdown from '~/branches/branch_sort_dropdown';
|
||||
import DeleteModal from '~/branches/branches_delete_modal';
|
||||
import initDiverganceGraph from '~/branches/divergence_graph';
|
||||
import initDeleteBranchButton from '~/branches/init_delete_branch_button';
|
||||
import initDeleteBranchModal from '~/branches/init_delete_branch_modal';
|
||||
|
||||
AjaxLoadingSpinner.init();
|
||||
new DeleteModal(); // eslint-disable-line no-new
|
||||
|
||||
const { divergingCountsEndpoint, defaultBranch } = document.querySelector(
|
||||
'.js-branch-list',
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import {
|
|||
I18N_FETCH_ERROR,
|
||||
} from '../constants';
|
||||
import getRunnersQuery from '../graphql/get_runners.query.graphql';
|
||||
import getRunnersCountQuery from '../graphql/get_runners_count.query.graphql';
|
||||
import {
|
||||
fromUrlQueryToSearch,
|
||||
fromSearchToUrl,
|
||||
|
|
@ -29,6 +30,17 @@ import {
|
|||
} from '../runner_search_utils';
|
||||
import { captureException } from '../sentry_utils';
|
||||
|
||||
const runnersCountSmartQuery = {
|
||||
query: getRunnersCountQuery,
|
||||
fetchPolicy: fetchPolicies.CACHE_AND_NETWORK,
|
||||
update(data) {
|
||||
return data?.runners?.count;
|
||||
},
|
||||
error(error) {
|
||||
this.reportToSentry(error);
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
name: 'AdminRunnersApp',
|
||||
components: {
|
||||
|
|
@ -51,22 +63,6 @@ export default {
|
|||
type: String,
|
||||
required: true,
|
||||
},
|
||||
allRunnersCount: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
instanceRunnersCount: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
groupRunnersCount: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
projectRunnersCount: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
|
@ -100,11 +96,49 @@ export default {
|
|||
this.reportToSentry(error);
|
||||
},
|
||||
},
|
||||
allRunnersCount: {
|
||||
...runnersCountSmartQuery,
|
||||
variables() {
|
||||
return this.countVariables;
|
||||
},
|
||||
},
|
||||
instanceRunnersCount: {
|
||||
...runnersCountSmartQuery,
|
||||
variables() {
|
||||
return {
|
||||
...this.countVariables,
|
||||
type: INSTANCE_TYPE,
|
||||
};
|
||||
},
|
||||
},
|
||||
groupRunnersCount: {
|
||||
...runnersCountSmartQuery,
|
||||
variables() {
|
||||
return {
|
||||
...this.countVariables,
|
||||
type: GROUP_TYPE,
|
||||
};
|
||||
},
|
||||
},
|
||||
projectRunnersCount: {
|
||||
...runnersCountSmartQuery,
|
||||
variables() {
|
||||
return {
|
||||
...this.countVariables,
|
||||
type: PROJECT_TYPE,
|
||||
};
|
||||
},
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
variables() {
|
||||
return fromSearchToVariables(this.search);
|
||||
},
|
||||
countVariables() {
|
||||
// Exclude pagination variables, leave only filters variables
|
||||
const { sort, before, last, after, first, ...countVariables } = this.variables;
|
||||
return countVariables;
|
||||
},
|
||||
runnersLoading() {
|
||||
return this.$apollo.queries.runners.loading;
|
||||
},
|
||||
|
|
@ -125,7 +159,7 @@ export default {
|
|||
search: {
|
||||
deep: true,
|
||||
handler() {
|
||||
// TODO Implement back button reponse using onpopstate
|
||||
// TODO Implement back button response using onpopstate
|
||||
updateHistory({
|
||||
url: fromSearchToUrl(this.search),
|
||||
title: document.title,
|
||||
|
|
@ -174,7 +208,7 @@ export default {
|
|||
>
|
||||
<template #title="{ tab }">
|
||||
{{ tab.title }}
|
||||
<gl-badge v-if="tabCount(tab)" class="gl-ml-1" size="sm">
|
||||
<gl-badge v-if="typeof tabCount(tab) == 'number'" class="gl-ml-1" size="sm">
|
||||
{{ tabCount(tab) }}
|
||||
</gl-badge>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -27,16 +27,7 @@ export const initAdminRunners = (selector = '#js-admin-runners') => {
|
|||
|
||||
// TODO `activeRunnersCount` should be implemented using a GraphQL API
|
||||
// https://gitlab.com/gitlab-org/gitlab/-/issues/333806
|
||||
const {
|
||||
runnerInstallHelpPage,
|
||||
registrationToken,
|
||||
|
||||
activeRunnersCount,
|
||||
allRunnersCount,
|
||||
instanceRunnersCount,
|
||||
groupRunnersCount,
|
||||
projectRunnersCount,
|
||||
} = el.dataset;
|
||||
const { runnerInstallHelpPage, registrationToken, activeRunnersCount } = el.dataset;
|
||||
|
||||
const apolloProvider = new VueApollo({
|
||||
defaultClient: createDefaultClient(),
|
||||
|
|
@ -53,13 +44,9 @@ export const initAdminRunners = (selector = '#js-admin-runners') => {
|
|||
props: {
|
||||
registrationToken,
|
||||
|
||||
// All runner counts are returned as formatted
|
||||
// Runner counts are returned as formatted
|
||||
// strings, we do not use `parseInt`.
|
||||
activeRunnersCount,
|
||||
allRunnersCount,
|
||||
instanceRunnersCount,
|
||||
groupRunnersCount,
|
||||
projectRunnersCount,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
query getRunnersCount(
|
||||
$status: CiRunnerStatus
|
||||
$type: CiRunnerType
|
||||
$tagList: [String!]
|
||||
$search: String
|
||||
) {
|
||||
runners(status: $status, type: $type, tagList: $tagList, search: $search) {
|
||||
count
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
<script>
|
||||
import { GlTabs, GlTab, GlBadge } from '@gitlab/ui';
|
||||
import { formatNumber } from '~/locale';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
|
|
@ -29,6 +30,9 @@ export default {
|
|||
isTabCountNumeric(tab) {
|
||||
return Number.isInteger(this.tabCounts[tab.name]);
|
||||
},
|
||||
formatNumber(count) {
|
||||
return formatNumber(count);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
@ -55,7 +59,7 @@ export default {
|
|||
size="sm"
|
||||
class="gl-tab-counter-badge"
|
||||
>
|
||||
{{ tabCounts[tab.name] }}
|
||||
{{ formatNumber(tabCounts[tab.name]) }}
|
||||
</gl-badge>
|
||||
</template>
|
||||
</gl-tab>
|
||||
|
|
|
|||
|
|
@ -67,12 +67,8 @@ module Ci
|
|||
runner_install_help_page: 'https://docs.gitlab.com/runner/install/',
|
||||
registration_token: Gitlab::CurrentSettings.runners_registration_token,
|
||||
|
||||
# All runner counts are returned as formatted strings
|
||||
active_runners_count: Ci::Runner.online.count.to_s,
|
||||
all_runners_count: limited_counter_with_delimiter(Ci::Runner),
|
||||
instance_runners_count: limited_counter_with_delimiter(Ci::Runner.instance_type),
|
||||
group_runners_count: limited_counter_with_delimiter(Ci::Runner.group_type),
|
||||
project_runners_count: limited_counter_with_delimiter(Ci::Runner.project_type)
|
||||
# Runner counts are returned as formatted strings
|
||||
active_runners_count: Ci::Runner.online.count.to_s
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ class CustomerRelations::Contact < ApplicationRecord
|
|||
validate :validate_email_format
|
||||
validate :unique_email_for_group_hierarchy
|
||||
|
||||
def self.find_ids_by_emails(group_id, emails)
|
||||
def self.find_ids_by_emails(group, emails)
|
||||
raise ArgumentError, "Cannot lookup more than #{MAX_PLUCK} emails" if emails.length > MAX_PLUCK
|
||||
|
||||
where(group_id: group_id, email: emails)
|
||||
where(group_id: group.self_and_ancestor_ids, email: emails)
|
||||
.pluck(:id)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class CustomerRelations::IssueContact < ApplicationRecord
|
|||
belongs_to :issue, optional: false, inverse_of: :customer_relations_contacts
|
||||
belongs_to :contact, optional: false, inverse_of: :issue_contacts
|
||||
|
||||
validate :contact_belongs_to_issue_group
|
||||
validate :contact_belongs_to_issue_group_or_ancestor
|
||||
|
||||
def self.find_contact_ids_by_emails(issue_id, emails)
|
||||
raise ArgumentError, "Cannot lookup more than #{MAX_PLUCK} emails" if emails.length > MAX_PLUCK
|
||||
|
|
@ -18,11 +18,11 @@ class CustomerRelations::IssueContact < ApplicationRecord
|
|||
|
||||
private
|
||||
|
||||
def contact_belongs_to_issue_group
|
||||
def contact_belongs_to_issue_group_or_ancestor
|
||||
return unless contact&.group_id
|
||||
return unless issue&.project&.namespace_id
|
||||
return if contact.group_id == issue.project.namespace_id
|
||||
return if issue.project.group&.self_and_ancestor_ids&.include?(contact.group_id)
|
||||
|
||||
errors.add(:base, _('The contact does not belong to the same group as the issue'))
|
||||
errors.add(:base, _('The contact does not belong to the issue group or an ancestor'))
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ module Issues
|
|||
end
|
||||
|
||||
def add_by_email
|
||||
contact_ids = ::CustomerRelations::Contact.find_ids_by_emails(project_group.id, params[:add_emails])
|
||||
contact_ids = ::CustomerRelations::Contact.find_ids_by_emails(project_group, params[:add_emails])
|
||||
add_by_id(contact_ids)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ module Projects
|
|||
move_before_destroy_relationships(source_project)
|
||||
# Reset is required in order to get the proper
|
||||
# uncached fork network method calls value.
|
||||
destroy_old_project(source_project.reset)
|
||||
::Gitlab::Database::QueryAnalyzers::PreventCrossDatabaseModification.allow_cross_database_modification_within_transaction(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/340256') do
|
||||
destroy_old_project(source_project.reset)
|
||||
end
|
||||
rename_project(source_project.name, source_project.path)
|
||||
|
||||
@project
|
||||
|
|
|
|||
|
|
@ -45,38 +45,4 @@
|
|||
|
||||
= render 'projects/buttons/download', project: @project, ref: branch.name, pipeline: @refs_pipelines[branch.name], class: 'gl-vertical-align-top'
|
||||
|
||||
- if Feature.enabled?(:delete_branch_confirmation_modals, @project, default_enabled: :yaml)
|
||||
= render 'projects/branches/delete_branch_modal_button', project: @project, branch: branch, merged: merged
|
||||
|
||||
- elsif can?(current_user, :push_code, @project)
|
||||
- if branch.name == @project.repository.root_ref
|
||||
- delete_default_branch_tooltip = s_('Branches|The default branch cannot be deleted')
|
||||
%span.gl-display-inline-block.has-tooltip{ title: delete_default_branch_tooltip }
|
||||
%button{ class: 'gl-button btn btn-default btn-icon disabled', disabled: true, 'aria-label' => delete_default_branch_tooltip }
|
||||
= sprite_icon('remove', css_class: 'gl-button-icon gl-icon')
|
||||
- elsif protected_branch?(@project, branch)
|
||||
- if can?(current_user, :push_to_delete_protected_branch, @project)
|
||||
- delete_protected_branch_tooltip = s_('Branches|Delete protected branch')
|
||||
%button{ class: 'gl-button btn btn-default btn-icon has-tooltip',
|
||||
title: delete_protected_branch_tooltip,
|
||||
'aria-label' => delete_protected_branch_tooltip,
|
||||
data: { toggle: 'modal',
|
||||
target: '#modal-delete-branch',
|
||||
delete_path: project_branch_path(@project, branch.name),
|
||||
branch_name: branch.name,
|
||||
is_merged: ('true' if merged) } }
|
||||
= sprite_icon('remove', css_class: 'gl-button-icon gl-icon')
|
||||
- else
|
||||
- delete_protected_branch_disabled_tooltip = s_('Branches|Only a project maintainer or owner can delete a protected branch')
|
||||
%span.has-tooltip{ title: delete_protected_branch_disabled_tooltip }
|
||||
%button{ class: 'gl-button btn btn-default btn-icon disabled', disabled: true, 'aria-label' => delete_protected_branch_disabled_tooltip, data: { testid: 'remove-protected-branch' } }
|
||||
= sprite_icon('remove', css_class: 'gl-button-icon gl-icon')
|
||||
- else
|
||||
= link_to project_branch_path(@project, branch.name),
|
||||
class: 'gl-button btn btn-default btn-icon js-remove-row qa-remove-btn js-ajax-loading-spinner has-tooltip',
|
||||
title: s_('Branches|Delete branch'),
|
||||
method: :delete,
|
||||
data: { confirm: s_("Branches|Deleting the '%{branch_name}' branch cannot be undone. Are you sure?") % { branch_name: branch.name } },
|
||||
remote: true,
|
||||
'aria-label' => s_('Branches|Delete branch') do
|
||||
= sprite_icon('remove', css_class: 'gl-button-icon gl-icon')
|
||||
= render 'projects/branches/delete_branch_modal_button', project: @project, branch: branch, merged: merged
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
#modal-delete-branch.modal{ tabindex: -1 }
|
||||
.modal-dialog
|
||||
.modal-content
|
||||
.modal-header
|
||||
%h3.page-title
|
||||
- title_branch_name = capture do
|
||||
%span.js-branch-name.ref-name>[branch name]
|
||||
= s_("Branches|Delete protected branch '%{branch_name}'?").html_safe % { branch_name: title_branch_name }
|
||||
%button.close{ type: "button", "data-dismiss": "modal", "aria-label" => _('Close') }
|
||||
%span{ "aria-hidden": "true" } ×
|
||||
|
||||
.modal-body
|
||||
%p
|
||||
- branch_name = capture do
|
||||
%strong.js-branch-name.ref-name>[branch name]
|
||||
= s_('Branches|You’re about to permanently delete the protected branch %{branch_name}.').html_safe % { branch_name: branch_name }
|
||||
%p.js-not-merged
|
||||
- default_branch = capture do
|
||||
%span.ref-name= @repository.root_ref
|
||||
= s_('Branches|This branch hasn’t been merged into %{default_branch}.').html_safe % { default_branch: default_branch }
|
||||
= s_('Branches|To avoid data loss, consider merging this branch before deleting it.')
|
||||
%p
|
||||
- delete_protected_branch = capture do
|
||||
%strong
|
||||
= s_('Branches|Delete protected branch')
|
||||
= s_('Branches|Once you confirm and press %{delete_protected_branch}, it cannot be undone or recovered.').html_safe % { delete_protected_branch: delete_protected_branch }
|
||||
%p
|
||||
- branch_name_confirmation = capture do
|
||||
%kbd.js-branch-name [branch name]
|
||||
%strong
|
||||
= s_('Branches|To confirm, type %{branch_name_confirmation}:').html_safe % { branch_name_confirmation: branch_name_confirmation }
|
||||
|
||||
.form-group
|
||||
= text_field_tag 'delete_branch_input', '', class: 'form-control js-delete-branch-input'
|
||||
|
||||
.modal-footer
|
||||
%button.gl-button.btn.btn-default{ data: { dismiss: 'modal' } } Cancel
|
||||
= link_to s_('Branches|Delete protected branch'), '',
|
||||
class: "gl-button btn btn-danger js-delete-branch",
|
||||
title: s_('Branches|Delete branch'),
|
||||
method: :delete,
|
||||
'aria-label' => s_('Branches|Delete branch')
|
||||
|
|
@ -50,7 +50,5 @@
|
|||
.nothing-here-block
|
||||
= s_('Branches|No branches to show')
|
||||
|
||||
- if Feature.enabled?(:delete_branch_confirmation_modals, @project, default_enabled: :yaml) && can?(current_user, :push_code, @project)
|
||||
- if can?(current_user, :push_code, @project)
|
||||
.js-delete-branch-modal
|
||||
- elsif can?(current_user, :push_code, @project)
|
||||
= render 'projects/branches/delete_protected_modal'
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
name: delete_branch_confirmation_modals
|
||||
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56782
|
||||
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/329052
|
||||
milestone: '14.3'
|
||||
type: development
|
||||
group: group::expansion
|
||||
default_enabled: true
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddBloatEstimateToReindexAction < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
add_column :postgres_reindex_actions, :bloat_estimate_bytes_start, :bigint
|
||||
end
|
||||
end
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ChangeMrAllowMaintainerToPushDefault < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
with_lock_retries do
|
||||
change_column_default :merge_requests, :allow_maintainer_to_push, from: nil, to: true
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
change_column_default :merge_requests, :allow_maintainer_to_push, from: true, to: nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddHasExternalWikiTrigger < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::SchemaHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
FUNCTION_NAME = 'set_has_external_wiki'
|
||||
TRIGGER_ON_INSERT_NAME = 'trigger_has_external_wiki_on_insert'
|
||||
TRIGGER_ON_UPDATE_NAME = 'trigger_has_external_wiki_on_update'
|
||||
TRIGGER_ON_DELETE_NAME = 'trigger_has_external_wiki_on_delete'
|
||||
|
||||
def up
|
||||
create_trigger_function(FUNCTION_NAME, replace: true) do
|
||||
<<~SQL
|
||||
UPDATE projects SET has_external_wiki = COALESCE(NEW.active, FALSE)
|
||||
WHERE projects.id = COALESCE(NEW.project_id, OLD.project_id);
|
||||
RETURN NULL;
|
||||
SQL
|
||||
end
|
||||
|
||||
execute(<<~SQL)
|
||||
CREATE TRIGGER #{TRIGGER_ON_INSERT_NAME}
|
||||
AFTER INSERT ON services
|
||||
FOR EACH ROW
|
||||
WHEN (NEW.active = TRUE AND NEW.type = 'ExternalWikiService' AND NEW.project_id IS NOT NULL)
|
||||
EXECUTE FUNCTION #{FUNCTION_NAME}();
|
||||
SQL
|
||||
|
||||
execute(<<~SQL)
|
||||
CREATE TRIGGER #{TRIGGER_ON_UPDATE_NAME}
|
||||
AFTER UPDATE ON services
|
||||
FOR EACH ROW
|
||||
WHEN (NEW.type = 'ExternalWikiService' AND OLD.active != NEW.active AND NEW.project_id IS NOT NULL)
|
||||
EXECUTE FUNCTION #{FUNCTION_NAME}();
|
||||
SQL
|
||||
|
||||
execute(<<~SQL)
|
||||
CREATE TRIGGER #{TRIGGER_ON_DELETE_NAME}
|
||||
AFTER DELETE ON services
|
||||
FOR EACH ROW
|
||||
WHEN (OLD.type = 'ExternalWikiService' AND OLD.project_id IS NOT NULL)
|
||||
EXECUTE FUNCTION #{FUNCTION_NAME}();
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
drop_trigger(:services, TRIGGER_ON_INSERT_NAME)
|
||||
drop_trigger(:services, TRIGGER_ON_UPDATE_NAME)
|
||||
drop_trigger(:services, TRIGGER_ON_DELETE_NAME)
|
||||
drop_function(FUNCTION_NAME)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
class AddExpirationPolicyCompletedAtToContainerRepositories < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
add_column(:container_repositories, :expiration_policy_completed_at, :datetime_with_timezone)
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column(:container_repositories, :expiration_policy_completed_at)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddContainerRegistryCleanupTagsServiceMaxListSizeToApplicationSettings < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
add_column(:application_settings, :container_registry_cleanup_tags_service_max_list_size, :integer, default: 200, null: false)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddAppSettingsContainerRegCleanupTagsServiceMaxListSizeConstraint < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
CONSTRAINT_NAME = 'app_settings_container_reg_cleanup_tags_max_list_size_positive'
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_check_constraint :application_settings, 'container_registry_cleanup_tags_service_max_list_size >= 0', CONSTRAINT_NAME
|
||||
end
|
||||
|
||||
def down
|
||||
remove_check_constraint :application_settings, CONSTRAINT_NAME
|
||||
end
|
||||
end
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddCustomMappingColumnsToHttpIntegrations < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
add_column :alert_management_http_integrations, :payload_example, :jsonb, null: false, default: {}
|
||||
add_column :alert_management_http_integrations, :payload_attribute_mapping, :jsonb, null: false, default: {}
|
||||
end
|
||||
end
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddEpicBoardList < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
unless table_exists?(:boards_epic_lists)
|
||||
with_lock_retries do
|
||||
create_table :boards_epic_lists do |t|
|
||||
t.timestamps_with_timezone
|
||||
t.references :epic_board, index: true, foreign_key: { to_table: :boards_epic_boards, on_delete: :cascade }, null: false
|
||||
t.references :label, index: true, foreign_key: { on_delete: :cascade }
|
||||
t.integer :position
|
||||
t.integer :list_type, default: 1, limit: 2, null: false
|
||||
|
||||
t.index [:epic_board_id, :label_id], unique: true, where: 'list_type = 1', name: 'index_boards_epic_lists_on_epic_board_id_and_label_id'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
add_check_constraint :boards_epic_lists, '(list_type <> 1) OR ("position" IS NOT NULL AND "position" >= 0)', 'boards_epic_lists_position_constraint'
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
drop_table :boards_epic_lists
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DeleteMockDeploymentServiceRecords < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
if Rails.env.development?
|
||||
execute("DELETE FROM services WHERE type = 'MockDeploymentService'")
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
# no-op
|
||||
end
|
||||
end
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ChangeUniqueIndexOnSecurityFindings < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
OLD_INDEX_NAME = 'index_security_findings_on_uuid'
|
||||
NEW_INDEX_NAME = 'index_security_findings_on_uuid_and_scan_id'
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
class SecurityFinding < ActiveRecord::Base
|
||||
include EachBatch
|
||||
|
||||
self.table_name = 'security_findings'
|
||||
end
|
||||
|
||||
def up
|
||||
add_concurrent_index :security_findings, [:uuid, :scan_id], unique: true, name: NEW_INDEX_NAME
|
||||
|
||||
remove_concurrent_index_by_name :security_findings, OLD_INDEX_NAME
|
||||
end
|
||||
|
||||
def down
|
||||
# It is very unlikely that we rollback this migration but just in case if we have to,
|
||||
# we have to clear the table because there can be multiple records with the same UUID
|
||||
# which would break the creation of unique index on the `uuid` column.
|
||||
# We choose clearing the table because just removing the duplicated records would
|
||||
# cause data inconsistencies.
|
||||
SecurityFinding.each_batch(of: 10000) { |relation| relation.delete_all }
|
||||
|
||||
add_concurrent_index :security_findings, :uuid, unique: true, name: OLD_INDEX_NAME
|
||||
|
||||
remove_concurrent_index_by_name :security_findings, NEW_INDEX_NAME
|
||||
end
|
||||
end
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateNamespacePackageSettings < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
with_lock_retries do
|
||||
create_table :namespace_package_settings, if_not_exists: true, id: false do |t|
|
||||
t.references :namespace, primary_key: true, index: false, default: nil, foreign_key: { to_table: :namespaces, on_delete: :cascade }, type: :bigint
|
||||
t.boolean :maven_duplicates_allowed, null: false, default: true
|
||||
t.text :maven_duplicate_exception_regex, null: false, default: ''
|
||||
end
|
||||
end
|
||||
|
||||
add_text_limit :namespace_package_settings, :maven_duplicate_exception_regex, 255
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :namespace_package_settings
|
||||
end
|
||||
end
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddSquashCommitShaIndex < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
INDEX_NAME = "index_merge_requests_on_target_project_id_and_squash_commit_sha"
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_concurrent_index :merge_requests,
|
||||
[:target_project_id, :squash_commit_sha],
|
||||
name: INDEX_NAME
|
||||
end
|
||||
|
||||
def down
|
||||
remove_concurrent_index :merge_requests,
|
||||
[:target_project_id, :squash_commit_sha],
|
||||
name: INDEX_NAME
|
||||
end
|
||||
end
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddDevopsAdoptionSnapshotRangeEnd < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
add_column :analytics_devops_adoption_snapshots, :end_time, :datetime_with_timezone
|
||||
end
|
||||
end
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddGroupMergeRequestApprovalSettings < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
with_lock_retries do
|
||||
create_table :group_merge_request_approval_settings, id: false do |t|
|
||||
t.timestamps_with_timezone null: false
|
||||
t.references :group, references: :namespaces, primary_key: true, default: nil, index: false,
|
||||
foreign_key: { to_table: :namespaces, on_delete: :cascade }
|
||||
t.boolean :allow_author_approval, null: false, default: false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
drop_table :group_merge_request_approval_settings
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ChangePagesDeploymentSizeToBigint < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
change_column_type_concurrently :pages_deployments, :size, :bigint
|
||||
end
|
||||
|
||||
def down
|
||||
undo_change_column_type_concurrently :pages_deployments, :size
|
||||
end
|
||||
end
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateElasticReindexingSubtasks < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
class ReindexingTask < ActiveRecord::Base
|
||||
self.table_name = 'elastic_reindexing_tasks'
|
||||
end
|
||||
|
||||
class ReindexingSubtask < ActiveRecord::Base
|
||||
self.table_name = 'elastic_reindexing_subtasks'
|
||||
end
|
||||
|
||||
def up
|
||||
unless table_exists?(:elastic_reindexing_subtasks)
|
||||
create_table :elastic_reindexing_subtasks do |t|
|
||||
t.references :elastic_reindexing_task, foreign_key: { on_delete: :cascade }, null: false
|
||||
t.text :alias_name, null: false
|
||||
t.text :index_name_from, null: false
|
||||
t.text :index_name_to, null: false
|
||||
t.text :elastic_task, null: false
|
||||
t.integer :documents_count_target
|
||||
t.integer :documents_count
|
||||
t.timestamps_with_timezone null: false
|
||||
end
|
||||
end
|
||||
|
||||
add_text_limit :elastic_reindexing_subtasks, :index_name_from, 255
|
||||
add_text_limit :elastic_reindexing_subtasks, :index_name_to, 255
|
||||
add_text_limit :elastic_reindexing_subtasks, :elastic_task, 255
|
||||
add_text_limit :elastic_reindexing_subtasks, :alias_name, 255
|
||||
|
||||
ReindexingTask.find_each do |task|
|
||||
next if task.index_name_from.blank? || task.index_name_to.blank? || task.elastic_task.blank?
|
||||
next if ReindexingSubtask.where(elastic_reindexing_task_id: task.id).exists?
|
||||
|
||||
ReindexingSubtask.create(
|
||||
elastic_reindexing_task_id: task.id,
|
||||
documents_count_target: task.documents_count_target,
|
||||
documents_count: task.documents_count,
|
||||
alias_name: 'gitlab-production',
|
||||
index_name_from: task.index_name_from,
|
||||
index_name_to: task.index_name_to,
|
||||
elastic_task: task.elastic_task
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :elastic_reindexing_subtasks
|
||||
end
|
||||
end
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateAdminNotes < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
create_table_with_constraints :namespace_admin_notes do |t|
|
||||
t.timestamps_with_timezone
|
||||
t.references :namespace, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.text :note
|
||||
|
||||
t.text_limit :note, 1000
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :namespace_admin_notes
|
||||
end
|
||||
end
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddDevopsSnapshotIndex < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
INDEX_NAME = 'index_on_snapshots_segment_id_end_time'
|
||||
|
||||
def up
|
||||
add_concurrent_index :analytics_devops_adoption_snapshots, [:segment_id, :end_time], name: INDEX_NAME
|
||||
end
|
||||
|
||||
def down
|
||||
remove_concurrent_index_by_name :analytics_devops_adoption_snapshots, INDEX_NAME
|
||||
end
|
||||
end
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ChangeClustersHelmMajorVersionDefaultTo3 < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
change_column_default(:clusters, :helm_major_version, from: 2, to: 3)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddServiceDeskReplyToIsNotNullIndexOnIssues < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
# no-op, the migration's version number was lowered to be executed earlier than db/post_migrate/20201128210234_schedule_populate_issue_email_participants.rb
|
||||
#
|
||||
# The new migration is located here: db/migrate/20201128210000_add_service_desk_reply_to_is_not_null_index_on_issues_fix.rb
|
||||
end
|
||||
end
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class UpdateTrustedAppsToConfidential < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
INDEX_NAME = 'tmp_index_oauth_applications_on_id_where_trusted'
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_concurrent_index :oauth_applications, :id, where: 'trusted = true', name: INDEX_NAME
|
||||
|
||||
execute('UPDATE oauth_applications SET confidential = true WHERE trusted = true')
|
||||
end
|
||||
|
||||
def down
|
||||
# We won't be able to tell which trusted applications weren't confidential before the migration
|
||||
# and setting all trusted applications are not confidential would introduce security issues
|
||||
|
||||
remove_concurrent_index_by_name :oauth_applications, INDEX_NAME
|
||||
end
|
||||
end
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddRestrictUserDefinedVariablesToProjectSettings < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
with_lock_retries do
|
||||
add_column :project_ci_cd_settings, :restrict_user_defined_variables, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
remove_column :project_ci_cd_settings, :restrict_user_defined_variables
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class MigrateCoverageReportWorker < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
sidekiq_queue_migrate 'ci_pipelines_create_artifact', to: 'ci_pipeline_artifacts_coverage_report' # rubocop:disable Migration/SidekiqQueueMigrate
|
||||
end
|
||||
|
||||
def down
|
||||
sidekiq_queue_migrate 'ci_pipeline_artifacts_coverage_report', to: 'ci_pipelines_create_artifact' # rubocop:disable Migration/SidekiqQueueMigrate
|
||||
end
|
||||
end
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateIterationsCadence < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
create_table_with_constraints :iterations_cadences do |t|
|
||||
t.references :group, null: false, foreign_key: { to_table: :namespaces, on_delete: :cascade }
|
||||
t.timestamps_with_timezone null: false
|
||||
t.date :start_date, null: false
|
||||
t.date :last_run_date
|
||||
t.integer :duration_in_weeks
|
||||
t.integer :iterations_in_advance
|
||||
t.boolean :active, default: true, null: false
|
||||
t.boolean :automatic, default: true, null: false
|
||||
t.text :title, null: false
|
||||
|
||||
t.text_limit :title, 255
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :iterations_cadences if table_exists?(:iterations_cadences)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddIterationsCadenceToSprints < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
INDEX_NAME = 'index_sprints_iterations_cadence_id'
|
||||
|
||||
def up
|
||||
add_column :sprints, :iterations_cadence_id, :integer unless column_exists?(:sprints, :iterations_cadence_id)
|
||||
|
||||
add_concurrent_index :sprints, :iterations_cadence_id, name: INDEX_NAME
|
||||
add_concurrent_foreign_key :sprints, :iterations_cadences, column: :iterations_cadence_id, on_delete: :cascade
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :sprints, :iterations_cadence_id if column_exists?(:sprints, :iterations_cadence_id)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddDismissalReasonIntoVulnerabilityFeedbackTable < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
add_column :vulnerability_feedback, :dismissal_reason, :smallint
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :vulnerability_feedback, :dismissal_reason
|
||||
end
|
||||
end
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddInvisibleCaptchaEnabledToSettings < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
add_column :application_settings, :invisible_captcha_enabled, :boolean, null: false, default: false
|
||||
end
|
||||
end
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddRateLimitingResponseTextToApplicationSettings < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
# rubocop:disable Migration/AddLimitToTextColumns
|
||||
# limit is added in 20210101110640_set_limit_for_rate_limiting_response_text
|
||||
def change
|
||||
add_column :application_settings, :rate_limiting_response_text, :text
|
||||
end
|
||||
# rubocop:enable Migration/AddLimitToTextColumns
|
||||
end
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateOnboardingProgress < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
with_lock_retries do
|
||||
create_table :onboarding_progresses do |t|
|
||||
t.references :namespace, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }
|
||||
t.timestamps_with_timezone null: false
|
||||
t.datetime_with_timezone :git_pull_at
|
||||
t.datetime_with_timezone :git_write_at
|
||||
t.datetime_with_timezone :merge_request_created_at
|
||||
t.datetime_with_timezone :pipeline_created_at
|
||||
t.datetime_with_timezone :user_added_at
|
||||
t.datetime_with_timezone :trial_started_at
|
||||
t.datetime_with_timezone :subscription_created_at
|
||||
t.datetime_with_timezone :required_mr_approvals_enabled_at
|
||||
t.datetime_with_timezone :code_owners_enabled_at
|
||||
t.datetime_with_timezone :scoped_label_created_at
|
||||
t.datetime_with_timezone :security_scan_enabled_at
|
||||
t.datetime_with_timezone :issue_auto_closed_at
|
||||
t.datetime_with_timezone :repository_imported_at
|
||||
t.datetime_with_timezone :repository_mirrored_at
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
drop_table :onboarding_progresses
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class SetLimitForRateLimitingResponseText < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_text_limit :application_settings, :rate_limiting_response_text, 255
|
||||
end
|
||||
|
||||
def down
|
||||
remove_text_limit :application_settings, :rate_limiting_response_text
|
||||
end
|
||||
end
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropTemporaryIndexOnCiBuilds < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
INDEX = 'tmp_build_stage_position_index'
|
||||
|
||||
def up
|
||||
remove_concurrent_index_by_name :ci_builds, INDEX
|
||||
end
|
||||
|
||||
def down
|
||||
add_concurrent_index :ci_builds, [:stage_id, :stage_idx], where: 'stage_idx IS NOT NULL', name: INDEX
|
||||
end
|
||||
end
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddEpicBoardPositionIndex < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
INDEX_NAME = 'index_boards_epic_board_positions_on_scoped_relative_position'
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_concurrent_index :boards_epic_board_positions, [:epic_board_id, :epic_id, :relative_position], name: INDEX_NAME
|
||||
end
|
||||
|
||||
def down
|
||||
remove_concurrent_index_by_name :boards_epic_board_positions, INDEX_NAME
|
||||
end
|
||||
end
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RenameAssetProxyWhitelistOnApplicationSettings < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers::V2
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
rename_column_concurrently :application_settings,
|
||||
:asset_proxy_whitelist,
|
||||
:asset_proxy_allowlist
|
||||
end
|
||||
|
||||
def down
|
||||
undo_rename_column_concurrently :application_settings,
|
||||
:asset_proxy_whitelist,
|
||||
:asset_proxy_allowlist
|
||||
end
|
||||
end
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddEntityColumnsToVulnerabilityOccurrences < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
# rubocop:disable Migration/AddLimitToTextColumns
|
||||
# limit is added in 20200501000002_add_text_limit_to_sprints_extended_title
|
||||
def change
|
||||
add_column :vulnerability_occurrences, :description, :text
|
||||
add_column :vulnerability_occurrences, :message, :text
|
||||
add_column :vulnerability_occurrences, :solution, :text
|
||||
add_column :vulnerability_occurrences, :cve, :text
|
||||
add_column :vulnerability_occurrences, :location, :jsonb
|
||||
end
|
||||
# rubocop:enable Migration/AddLimitToTextColumns
|
||||
end
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddTextLimitToVulnerabilityOccurrencesEntityColumns < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_text_limit :vulnerability_occurrences, :description, 15000
|
||||
add_text_limit :vulnerability_occurrences, :message, 3000
|
||||
add_text_limit :vulnerability_occurrences, :solution, 7000
|
||||
add_text_limit :vulnerability_occurrences, :cve, 48400
|
||||
end
|
||||
|
||||
def down
|
||||
remove_text_limit :vulnerability_occurrences, :description
|
||||
remove_text_limit :vulnerability_occurrences, :message
|
||||
remove_text_limit :vulnerability_occurrences, :solution
|
||||
remove_text_limit :vulnerability_occurrences, :cve
|
||||
end
|
||||
end
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddUniqueIndexForGolangPackages < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
INDEX_NAME = 'index_packages_on_project_id_name_version_unique_when_golang'
|
||||
PACKAGE_TYPE_GOLANG = 8
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_concurrent_index :packages_packages, [:project_id, :name, :version], unique: true, where: "package_type = #{PACKAGE_TYPE_GOLANG}", name: INDEX_NAME
|
||||
end
|
||||
|
||||
def down
|
||||
remove_concurrent_index_by_name(:packages_packages, INDEX_NAME)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropTmpIndexOnEmails < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
EMAIL_INDEX_NAME = 'tmp_index_for_email_unconfirmation_migration'
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
Gitlab::BackgroundMigration.steal('WrongfullyConfirmedEmailUnconfirmer')
|
||||
|
||||
remove_concurrent_index_by_name(:emails, EMAIL_INDEX_NAME)
|
||||
end
|
||||
|
||||
def down
|
||||
add_concurrent_index(:emails, :id, where: 'confirmed_at IS NOT NULL', name: EMAIL_INDEX_NAME)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# See https://docs.gitlab.com/ee/development/migration_style_guide.html
|
||||
# for more information on how to write migrations for GitLab.
|
||||
|
||||
class AddMergeRequestDiffCommitTrailers < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
with_lock_retries do
|
||||
add_column :merge_request_diff_commits, :trailers, :jsonb, default: {}, null: false
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
remove_column :merge_request_diff_commits, :trailers
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# This migration aligns an existing database schema with what we actually expect
|
||||
# and fixes inconsistencies with index names and similar issues.
|
||||
#
|
||||
# This is intended for GitLab.com, but can be run on any instance.
|
||||
class RenameIndexesOnGitLabCom < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
rename_index_if_exists :ldap_group_links, 'ldap_groups_pkey', 'ldap_group_links_pkey'
|
||||
|
||||
# Removes unique constraint, add unique index instead
|
||||
replace_unique_constraint_with_index :emails, :email, 'emails_email_key', 'index_emails_on_email'
|
||||
replace_unique_constraint_with_index :users, :confirmation_token, 'users_confirmation_token_key', 'index_users_on_confirmation_token'
|
||||
replace_unique_constraint_with_index :users, :reset_password_token, 'users_reset_password_token_key', 'index_users_on_reset_password_token'
|
||||
replace_unique_constraint_with_index :users, :email, 'users_email_key', 'index_users_on_email'
|
||||
|
||||
upgrade_to_primary_key(:schema_migrations, :version, 'schema_migrations_version_key', 'schema_migrations_pkey')
|
||||
end
|
||||
|
||||
def down
|
||||
# no-op
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def replace_unique_constraint_with_index(table, columns, old_name, new_name)
|
||||
return unless index_exists_by_name?(table, old_name)
|
||||
|
||||
add_concurrent_index table, columns, unique: true, name: new_name
|
||||
execute "ALTER TABLE #{quote_table_name(table)} DROP CONSTRAINT #{quote_table_name(old_name)}"
|
||||
end
|
||||
|
||||
def rename_index_if_exists(table, old_name, new_name)
|
||||
return unless index_exists_by_name?(table, old_name)
|
||||
return if index_exists_by_name?(table, new_name)
|
||||
|
||||
with_lock_retries do
|
||||
rename_index table, old_name, new_name
|
||||
end
|
||||
end
|
||||
|
||||
def upgrade_to_primary_key(table, column, old_name, new_name)
|
||||
return unless index_exists_by_name?(table, old_name)
|
||||
return if index_exists_by_name?(table, new_name)
|
||||
|
||||
return if primary_key(table)
|
||||
|
||||
execute "ALTER TABLE #{quote_table_name(table)} ADD CONSTRAINT #{new_name} PRIMARY KEY (#{column})"
|
||||
execute "ALTER TABLE #{quote_table_name(table)} DROP CONSTRAINT #{old_name}"
|
||||
end
|
||||
end
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddKeepLatestArtifactsToApplicationSettings < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
# This is named keep_latest_artifact for consistency with the project level setting but
|
||||
# turning it on keeps all (multiple) artifacts on the latest pipeline per ref
|
||||
add_column :application_settings, :keep_latest_artifact, :boolean, default: true, null: false
|
||||
end
|
||||
end
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddDiffTypeToMergeRequestDiffs < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
UNIQUE_INDEX_NAME = 'index_merge_request_diffs_on_unique_merge_request_id'
|
||||
|
||||
def up
|
||||
unless column_exists?(:merge_request_diffs, :diff_type)
|
||||
with_lock_retries do
|
||||
add_column :merge_request_diffs, :diff_type, :integer, null: false, limit: 2, default: 1
|
||||
end
|
||||
end
|
||||
|
||||
add_concurrent_index :merge_request_diffs, :merge_request_id, unique: true, where: 'diff_type = 2', name: UNIQUE_INDEX_NAME
|
||||
end
|
||||
|
||||
def down
|
||||
remove_concurrent_index_by_name(:merge_request_diffs, UNIQUE_INDEX_NAME)
|
||||
|
||||
if column_exists?(:merge_request_diffs, :diff_type)
|
||||
with_lock_retries do
|
||||
remove_column :merge_request_diffs, :diff_type
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# See https://docs.gitlab.com/ee/development/migration_style_guide.html
|
||||
# for more information on how to write migrations for GitLab.
|
||||
|
||||
class AddMergeRequestContextCommitTrailers < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
add_column :merge_request_context_commits, :trailers, :jsonb, default: {}, null: false
|
||||
end
|
||||
end
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class UpdateMaxImportSizeDefault < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
change_column_default(:application_settings, :max_import_size, from: 50, to: 0)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateDastProfiles < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
table_comment = { owner: 'group::dynamic analysis', description: 'Profile used to run a DAST on-demand scan' }
|
||||
|
||||
create_table_with_constraints :dast_profiles, comment: table_comment.to_json do |t| # rubocop:disable Migration/AddLimitToTextColumns
|
||||
t.references :project, null: false, foreign_key: false, index: false
|
||||
t.references :dast_site_profile, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.references :dast_scanner_profile, null: false, foreign_key: { on_delete: :cascade }
|
||||
|
||||
t.timestamps_with_timezone
|
||||
|
||||
# rubocop:disable Migration/AddLimitToTextColumns
|
||||
t.text :name, null: false
|
||||
t.text :description, null: false
|
||||
# rubocop:enable Migration/AddLimitToTextColumns
|
||||
|
||||
t.index [:project_id, :name], unique: true
|
||||
|
||||
t.text_limit :name, 255
|
||||
t.text_limit :description, 255
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
drop_table :dast_profiles
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddProjectFkForDastProfile < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_concurrent_foreign_key :dast_profiles, :projects, column: :project_id, on_delete: :cascade
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
remove_foreign_key :dast_profiles, column: :project_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddTemporaryIndexOnSecurityFindingsScanId < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
INDEX_NAME = 'tmp_index_on_security_findings_scan_id'
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_concurrent_index :security_findings, :scan_id, where: 'uuid is null', name: INDEX_NAME
|
||||
end
|
||||
|
||||
def down
|
||||
remove_concurrent_index_by_name :security_findings, INDEX_NAME
|
||||
end
|
||||
end
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropTmpIndexOnEmailsAgain < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
EMAIL_INDEX_NAME = 'tmp_index_for_email_unconfirmation_migration'
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
remove_concurrent_index_by_name(:emails, EMAIL_INDEX_NAME)
|
||||
end
|
||||
|
||||
def down
|
||||
add_concurrent_index(:emails, :id, where: 'confirmed_at IS NOT NULL', name: EMAIL_INDEX_NAME)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateComposerCacheFile < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
# rubocop:disable Migration/AddLimitToTextColumns
|
||||
create_table_with_constraints :packages_composer_cache_files do |t|
|
||||
t.timestamps_with_timezone
|
||||
|
||||
# record can be deleted after `delete_at`
|
||||
t.datetime_with_timezone :delete_at
|
||||
|
||||
# which namespace it belongs to
|
||||
t.integer :namespace_id, null: true
|
||||
|
||||
# file storage related fields
|
||||
t.integer :file_store, limit: 2, null: false, default: 1
|
||||
t.text :file, null: false
|
||||
t.binary :file_sha256, null: false
|
||||
|
||||
t.index [:namespace_id, :file_sha256], name: "index_packages_composer_cache_namespace_and_sha", using: :btree, unique: true
|
||||
t.foreign_key :namespaces, column: :namespace_id, on_delete: :nullify
|
||||
|
||||
t.text_limit :file, 255
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :packages_composer_cache_files
|
||||
end
|
||||
end
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddPipelineConfigurationFullPathToCompliancePipeline < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
# rubocop:disable Migration/AddLimitToTextColumns
|
||||
# limit is added in 20210119162812_add_text_limit_to_compliance_pipeline_configuration_full_path.rb
|
||||
def up
|
||||
add_column :compliance_management_frameworks, :pipeline_configuration_full_path, :text
|
||||
end
|
||||
# rubocop:enable Migration/AddLimitToTextColumns
|
||||
|
||||
def down
|
||||
remove_column :compliance_management_frameworks, :pipeline_configuration_full_path
|
||||
end
|
||||
end
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddConvertedAtToExperimentSubjects < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
add_column :experiment_subjects, :converted_at, :datetime_with_timezone
|
||||
end
|
||||
end
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddContextToExperimentSubjects < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
add_column :experiment_subjects, :context, :jsonb, default: {}, null: false
|
||||
end
|
||||
end
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveGroupIdTitleIndex < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
INDEX_NAME = 'index_labels_on_group_id_and_title_with_null_project_id'
|
||||
LABELS_TABLE = :labels
|
||||
|
||||
def up
|
||||
remove_concurrent_index_by_name LABELS_TABLE, INDEX_NAME
|
||||
end
|
||||
|
||||
def down
|
||||
add_concurrent_index LABELS_TABLE, [:group_id, :title], where: 'project_id IS NULL', name: INDEX_NAME
|
||||
end
|
||||
end
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddIndexesToOnboardingProgresses < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
CREATE_TRACK_INDEX_NAME = 'index_onboarding_progresses_for_create_track'
|
||||
VERIFY_TRACK_INDEX_NAME = 'index_onboarding_progresses_for_verify_track'
|
||||
TRIAL_TRACK_INDEX_NAME = 'index_onboarding_progresses_for_trial_track'
|
||||
TEAM_TRACK_INDEX_NAME = 'index_onboarding_progresses_for_team_track'
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_concurrent_index :onboarding_progresses, :created_at, where: 'git_write_at IS NULL', name: CREATE_TRACK_INDEX_NAME
|
||||
add_concurrent_index :onboarding_progresses, :git_write_at, where: 'git_write_at IS NOT NULL AND pipeline_created_at IS NULL', name: VERIFY_TRACK_INDEX_NAME
|
||||
add_concurrent_index :onboarding_progresses, 'GREATEST(git_write_at, pipeline_created_at)', where: 'git_write_at IS NOT NULL AND pipeline_created_at IS NOT NULL AND trial_started_at IS NULL', name: TRIAL_TRACK_INDEX_NAME
|
||||
add_concurrent_index :onboarding_progresses, 'GREATEST(git_write_at, pipeline_created_at, trial_started_at)', where: 'git_write_at IS NOT NULL AND pipeline_created_at IS NOT NULL AND trial_started_at IS NOT NULL AND user_added_at IS NULL', name: TEAM_TRACK_INDEX_NAME
|
||||
end
|
||||
|
||||
def down
|
||||
remove_concurrent_index_by_name :onboarding_progresses, CREATE_TRACK_INDEX_NAME
|
||||
remove_concurrent_index_by_name :onboarding_progresses, VERIFY_TRACK_INDEX_NAME
|
||||
remove_concurrent_index_by_name :onboarding_progresses, TRIAL_TRACK_INDEX_NAME
|
||||
remove_concurrent_index_by_name :onboarding_progresses, TEAM_TRACK_INDEX_NAME
|
||||
end
|
||||
end
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateGroupRepositoryStorageMove < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
unless table_exists?(:group_repository_storage_moves)
|
||||
with_lock_retries do
|
||||
create_table :group_repository_storage_moves do |t|
|
||||
t.timestamps_with_timezone
|
||||
t.references :group, references: :namespace, column: :group_id, index: true, null: false
|
||||
t.integer :state, limit: 2, default: 1, null: false
|
||||
t.text :source_storage_name, null: false
|
||||
t.text :destination_storage_name, null: false
|
||||
|
||||
t.foreign_key :namespaces, column: :group_id, on_delete: :cascade
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
add_text_limit(:group_repository_storage_moves, :source_storage_name, 255, constraint_name: 'group_repository_storage_moves_source_storage_name')
|
||||
add_text_limit(:group_repository_storage_moves, :destination_storage_name, 255, constraint_name: 'group_repository_storage_moves_destination_storage_name')
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
drop_table :group_repository_storage_moves
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddHasExternalIssueTrackerTrigger < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::SchemaHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
FUNCTION_NAME = 'set_has_external_issue_tracker'
|
||||
TRIGGER_ON_INSERT_NAME = 'trigger_has_external_issue_tracker_on_insert'
|
||||
TRIGGER_ON_UPDATE_NAME = 'trigger_has_external_issue_tracker_on_update'
|
||||
TRIGGER_ON_DELETE_NAME = 'trigger_has_external_issue_tracker_on_delete'
|
||||
|
||||
def up
|
||||
create_trigger_function(FUNCTION_NAME, replace: true) do
|
||||
<<~SQL
|
||||
UPDATE projects SET has_external_issue_tracker = (
|
||||
EXISTS
|
||||
(
|
||||
SELECT 1
|
||||
FROM services
|
||||
WHERE project_id = COALESCE(NEW.project_id, OLD.project_id)
|
||||
AND active = TRUE
|
||||
AND category = 'issue_tracker'
|
||||
)
|
||||
)
|
||||
WHERE projects.id = COALESCE(NEW.project_id, OLD.project_id);
|
||||
RETURN NULL;
|
||||
SQL
|
||||
end
|
||||
|
||||
execute(<<~SQL)
|
||||
CREATE TRIGGER #{TRIGGER_ON_INSERT_NAME}
|
||||
AFTER INSERT ON services
|
||||
FOR EACH ROW
|
||||
WHEN (NEW.category = 'issue_tracker' AND NEW.active = TRUE AND NEW.project_id IS NOT NULL)
|
||||
EXECUTE FUNCTION #{FUNCTION_NAME}();
|
||||
SQL
|
||||
|
||||
execute(<<~SQL)
|
||||
CREATE TRIGGER #{TRIGGER_ON_UPDATE_NAME}
|
||||
AFTER UPDATE ON services
|
||||
FOR EACH ROW
|
||||
WHEN (NEW.category = 'issue_tracker' AND OLD.active != NEW.active AND NEW.project_id IS NOT NULL)
|
||||
EXECUTE FUNCTION #{FUNCTION_NAME}();
|
||||
SQL
|
||||
|
||||
execute(<<~SQL)
|
||||
CREATE TRIGGER #{TRIGGER_ON_DELETE_NAME}
|
||||
AFTER DELETE ON services
|
||||
FOR EACH ROW
|
||||
WHEN (OLD.category = 'issue_tracker' AND OLD.active = TRUE AND OLD.project_id IS NOT NULL)
|
||||
EXECUTE FUNCTION #{FUNCTION_NAME}();
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
drop_trigger(:services, TRIGGER_ON_INSERT_NAME)
|
||||
drop_trigger(:services, TRIGGER_ON_UPDATE_NAME)
|
||||
drop_trigger(:services, TRIGGER_ON_DELETE_NAME)
|
||||
drop_function(FUNCTION_NAME)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddEnforceSshKeyExpirationToApplicationSettings < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
add_column :application_settings, :enforce_ssh_key_expiration, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddProxySettingsToJiraTrackerData < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
add_column :jira_tracker_data, :encrypted_proxy_address, :text
|
||||
add_column :jira_tracker_data, :encrypted_proxy_address_iv, :text
|
||||
add_column :jira_tracker_data, :encrypted_proxy_port, :text
|
||||
add_column :jira_tracker_data, :encrypted_proxy_port_iv, :text
|
||||
add_column :jira_tracker_data, :encrypted_proxy_username, :text
|
||||
add_column :jira_tracker_data, :encrypted_proxy_username_iv, :text
|
||||
add_column :jira_tracker_data, :encrypted_proxy_password, :text
|
||||
add_column :jira_tracker_data, :encrypted_proxy_password_iv, :text
|
||||
end
|
||||
end
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddTextLimitToCompliancePipelineConfigurationFullPath < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_text_limit :compliance_management_frameworks, :pipeline_configuration_full_path, 255
|
||||
end
|
||||
|
||||
def down
|
||||
remove_text_limit :compliance_management_frameworks, :pipeline_configuration_full_path
|
||||
end
|
||||
end
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ExtendIndexOnCiBuildsMetadata < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
OLD_INDEX = :index_ci_builds_metadata_on_build_id_and_interruptible
|
||||
NEW_INDEX = :index_ci_builds_metadata_on_build_id_and_id_and_interruptible
|
||||
|
||||
TABLE = :ci_builds_metadata
|
||||
|
||||
def up
|
||||
create_covering_index(TABLE, NEW_INDEX)
|
||||
|
||||
remove_concurrent_index_by_name TABLE, OLD_INDEX
|
||||
end
|
||||
|
||||
def down
|
||||
add_concurrent_index TABLE, :build_id, where: 'interruptible = true', name: OLD_INDEX
|
||||
|
||||
remove_concurrent_index_by_name TABLE, NEW_INDEX
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_covering_index(table, name)
|
||||
return if index_exists_by_name?(table, name)
|
||||
|
||||
disable_statement_timeout do
|
||||
execute <<~SQL
|
||||
CREATE INDEX CONCURRENTLY #{name}
|
||||
ON #{table} (build_id) INCLUDE (id)
|
||||
WHERE interruptible = true
|
||||
SQL
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DeleteOauthApplicationsTmpIndex < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
INDEX_NAME = 'tmp_index_oauth_applications_on_id_where_trusted'
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
remove_concurrent_index_by_name :oauth_applications, INDEX_NAME
|
||||
end
|
||||
|
||||
def down
|
||||
add_concurrent_index :oauth_applications, :id, where: 'trusted = true', name: INDEX_NAME
|
||||
end
|
||||
end
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveRepositoryReadOnlyToGroups < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
if column_exists?(:namespaces, :repository_read_only)
|
||||
with_lock_retries do
|
||||
remove_column :namespaces, :repository_read_only # rubocop:disable Migration/RemoveColumn
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
unless column_exists?(:namespaces, :repository_read_only)
|
||||
with_lock_retries do
|
||||
add_column :namespaces, :repository_read_only, :boolean, default: false, null: false # rubocop:disable Migration/AddColumnsToWideTables
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddDevopsAdoptionGroupSegment < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column :analytics_devops_adoption_segments, :namespace_id, :integer, if_not_exists: true
|
||||
add_concurrent_index :analytics_devops_adoption_segments, :namespace_id, unique: true
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :analytics_devops_adoption_segments, :namespace_id
|
||||
end
|
||||
end
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class OptionalDevopsAdoptionSegmentName < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
INDEX_NAME = 'index_analytics_devops_adoption_segments_on_name'
|
||||
|
||||
def up
|
||||
change_column_null :analytics_devops_adoption_segments, :name, true
|
||||
remove_concurrent_index_by_name :analytics_devops_adoption_segments, INDEX_NAME
|
||||
end
|
||||
|
||||
def down
|
||||
transaction do
|
||||
execute "DELETE FROM analytics_devops_adoption_segments WHERE name IS NULL"
|
||||
change_column_null :analytics_devops_adoption_segments, :name, false
|
||||
end
|
||||
add_concurrent_index :analytics_devops_adoption_segments, :name, unique: true, name: INDEX_NAME
|
||||
end
|
||||
end
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddRepositoryReadOnlyToNamespaceSettings < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
with_lock_retries do
|
||||
add_column :namespace_settings, :repository_read_only, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
remove_column :namespace_settings, :repository_read_only
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddStateToMergeRequestReviewers < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
REVIEW_DEFAULT_STATE = 0
|
||||
|
||||
def change
|
||||
add_column :merge_request_reviewers, :state, :smallint, default: REVIEW_DEFAULT_STATE, null: false
|
||||
end
|
||||
end
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddPipelineStepToBulkImportsFailures < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
unless column_exists?(:bulk_import_failures, :pipeline_step, :text)
|
||||
with_lock_retries do
|
||||
add_column :bulk_import_failures, :pipeline_step, :text
|
||||
end
|
||||
end
|
||||
|
||||
add_text_limit :bulk_import_failures, :pipeline_step, 255
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
remove_column :bulk_import_failures, :pipeline_step
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddDevopsAdoptionSegmentNamespaceFk < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_concurrent_foreign_key :analytics_devops_adoption_segments, :namespaces, column: :namespace_id
|
||||
end
|
||||
|
||||
def down
|
||||
remove_foreign_key_if_exists :analytics_devops_adoption_segments, :namespaces, column: :namespace_id
|
||||
end
|
||||
end
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddSecurityDashboardAccessLevelIntoProjectFeatures < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
PRIVATE_ACCESS_LEVEL = 10
|
||||
|
||||
def up
|
||||
with_lock_retries do
|
||||
add_column :project_features, :security_and_compliance_access_level, :integer, default: PRIVATE_ACCESS_LEVEL, null: false
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
remove_column :project_features, :security_and_compliance_access_level
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddUniqueIndexServicesProjectIdAndType < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
INDEX_NAME = 'index_services_on_project_id_and_type_unique'
|
||||
|
||||
def up
|
||||
add_concurrent_index :services, [:project_id, :type], name: INDEX_NAME, unique: true
|
||||
end
|
||||
|
||||
def down
|
||||
remove_concurrent_index_by_name :services, name: INDEX_NAME
|
||||
end
|
||||
end
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveIndexServicesProjectIdAndType < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
INDEX_NAME = 'index_services_on_project_id_and_type'
|
||||
|
||||
# Replaced by the index added in 20210126091713_add_unique_index_services_project_id_and_type.rb
|
||||
def up
|
||||
remove_concurrent_index_by_name :services, name: INDEX_NAME
|
||||
end
|
||||
|
||||
def down
|
||||
add_concurrent_index :services, [:project_id, :type], name: INDEX_NAME
|
||||
end
|
||||
end
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddRubygemsMaxFileSizeToPlanLimits < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
add_column :plan_limits, :rubygems_max_file_size, :bigint, default: 3.gigabytes, null: false
|
||||
end
|
||||
end
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddSubgroupEventsToWebHooks < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
add_column :web_hooks, :subgroup_events, :boolean, null: false, default: false
|
||||
end
|
||||
end
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddOldestMergeRequestsIndex < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
# replaced by db/migrate/20210201140434_add_oldest_merge_requests_index_again.rb
|
||||
end
|
||||
|
||||
def down
|
||||
# replaced by db/migrate/20210201140434_add_oldest_merge_requests_index_again.rb
|
||||
end
|
||||
end
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddIterationsCadenceDateRangeConstraint < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
with_lock_retries do
|
||||
execute <<~SQL
|
||||
ALTER TABLE sprints
|
||||
ADD CONSTRAINT iteration_start_and_due_date_iterations_cadence_id_constraint
|
||||
EXCLUDE USING gist
|
||||
( iterations_cadence_id WITH =,
|
||||
daterange(start_date, due_date, '[]') WITH &&
|
||||
)
|
||||
WHERE (group_id IS NOT NULL)
|
||||
SQL
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
execute <<~SQL
|
||||
ALTER TABLE sprints
|
||||
DROP CONSTRAINT IF EXISTS iteration_start_and_due_date_iterations_cadence_id_constraint
|
||||
SQL
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveIterationGroupDateRangeConstraint < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
with_lock_retries do
|
||||
execute <<~SQL
|
||||
ALTER TABLE sprints
|
||||
DROP CONSTRAINT IF EXISTS iteration_start_and_due_daterange_group_id_constraint
|
||||
SQL
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
execute <<~SQL
|
||||
ALTER TABLE sprints
|
||||
ADD CONSTRAINT iteration_start_and_due_daterange_group_id_constraint
|
||||
EXCLUDE USING gist
|
||||
( group_id WITH =,
|
||||
daterange(start_date, due_date, '[]') WITH &&
|
||||
)
|
||||
WHERE (group_id IS NOT NULL)
|
||||
SQL
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddGitTwoFactorSessionExpiryToApplicationSettings < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
def change
|
||||
add_column :application_settings, :git_two_factor_session_expiry, :integer, default: 15, null: false
|
||||
end
|
||||
end
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddPreventMergeWithoutJiraIssueToProjectSettings < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
with_lock_retries do
|
||||
add_column :project_settings, :prevent_merge_without_jira_issue, :boolean, null: false, default: false
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
remove_column :project_settings, :prevent_merge_without_jira_issue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddAutoDeleteAtToEnvironments < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
with_lock_retries do
|
||||
add_column :environments, :auto_delete_at, :datetime_with_timezone
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
with_lock_retries do
|
||||
remove_column :environments, :auto_delete_at
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddContentTypeToDependencyProxyManifests < ActiveRecord::Migration[6.0]
|
||||
DOWNTIME = false
|
||||
|
||||
# rubocop:disable Migration/AddLimitToTextColumns
|
||||
# limit is added in 20210128140232_add_text_limit_to_dependency_proxy_manifests_content_type.rb
|
||||
def change
|
||||
add_column :dependency_proxy_manifests, :content_type, :text
|
||||
end
|
||||
# rubocop:enable Migration/AddLimitToTextColumns
|
||||
end
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddTextLimitToDependencyProxyManifestsContentType < ActiveRecord::Migration[6.0]
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_text_limit :dependency_proxy_manifests, :content_type, 255
|
||||
end
|
||||
|
||||
def down
|
||||
remove_text_limit :dependency_proxy_manifests, :content_type
|
||||
end
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue