Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-11-15 21:14:31 +00:00
parent 4481a56a94
commit c568cb4dbc
2566 changed files with 15791 additions and 36717 deletions

View File

@ -1,7 +1,80 @@
<script>
export default {};
import { GlLoadingIcon, GlTable } from '@gitlab/ui';
import createFlash from '~/flash';
import { s__, __ } from '~/locale';
import getGroupContactsQuery from './queries/get_group_contacts.query.graphql';
export default {
components: {
GlLoadingIcon,
GlTable,
},
inject: ['groupFullPath'],
data() {
return { contacts: [] };
},
apollo: {
contacts: {
query() {
return getGroupContactsQuery;
},
variables() {
return {
groupFullPath: this.groupFullPath,
};
},
update(data) {
return this.extractContacts(data);
},
error(error) {
createFlash({
message: __('Something went wrong. Please try again.'),
error,
captureError: true,
});
},
},
},
computed: {
isLoading() {
return this.$apollo.queries.contacts.loading;
},
},
methods: {
extractContacts(data) {
const contacts = data?.group?.contacts?.nodes || [];
return contacts.slice().sort((a, b) => a.firstName.localeCompare(b.firstName));
},
},
fields: [
{ key: 'firstName', sortable: true },
{ key: 'lastName', sortable: true },
{ key: 'email', sortable: true },
{ key: 'phone', sortable: true },
{ key: 'description', sortable: true },
{
key: 'organization',
formatter: (organization) => {
return organization?.name;
},
sortable: true,
},
],
i18n: {
emptyText: s__('Crm|No contacts found'),
},
};
</script>
<template>
<div></div>
<div>
<gl-loading-icon v-if="isLoading" class="gl-mt-5" size="lg" />
<gl-table
v-else
:items="contacts"
:fields="$options.fields"
:empty-text="$options.i18n.emptyText"
show-empty
/>
</div>
</template>

View File

@ -0,0 +1,22 @@
query contacts($groupFullPath: ID!) {
group(fullPath: $groupFullPath) {
__typename
id
contacts {
nodes {
__typename
id
firstName
lastName
email
phone
description
organization {
__typename
id
name
}
}
}
}
}

View File

@ -1,15 +1,25 @@
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql';
import CrmContactsRoot from './components/contacts_root.vue';
Vue.use(VueApollo);
export default () => {
const el = document.getElementById('js-crm-contacts-app');
const apolloProvider = new VueApollo({
defaultClient: createDefaultClient(),
});
if (!el) {
return false;
}
return new Vue({
el,
apolloProvider,
provide: { groupFullPath: el.dataset.groupFullPath },
render(createElement) {
return createElement(CrmContactsRoot);
},

View File

@ -18,12 +18,36 @@ export default {
type: String,
required: true,
},
isFork: {
type: Boolean,
required: true,
},
issuesCount: {
type: Number,
required: true,
},
mergeRequestsCount: {
type: Number,
required: true,
},
forksCount: {
type: Number,
required: true,
},
starsCount: {
type: Number,
required: true,
},
},
strings: {
alertTitle: __('You are about to permanently delete this project'),
alertBody: __(
'Once a project is permanently deleted, it %{strongStart}cannot be recovered%{strongEnd}. Permanently deleting this project will %{strongStart}immediately delete%{strongEnd} its repositories and %{strongStart}all related resources%{strongEnd}, including issues, merge requests etc.',
),
isNotForkMessage: __(
'This project is %{strongStart}NOT%{strongEnd} a fork, and has the following:',
),
isForkMessage: __('This forked project has the following:'),
},
};
</script>
@ -37,6 +61,38 @@ export default {
:title="$options.strings.alertTitle"
:dismissible="false"
>
<p>
<gl-sprintf v-if="isFork" :message="$options.strings.isForkMessage" />
<gl-sprintf v-else :message="$options.strings.isNotForkMessage">
<template #strong="{ content }">
<strong>{{ content }}</strong>
</template>
</gl-sprintf>
</p>
<ul>
<li>
<gl-sprintf :message="n__('%d issue', '%d issues', issuesCount)">
<template #issuesCount>{{ issuesCount }}</template>
</gl-sprintf>
</li>
<li>
<gl-sprintf
:message="n__('%d merge requests', '%d merge requests', mergeRequestsCount)"
>
<template #mergeRequestsCount>{{ mergeRequestsCount }}</template>
</gl-sprintf>
</li>
<li>
<gl-sprintf :message="n__('%d fork', '%d forks', forksCount)">
<template #forksCount>{{ forksCount }}</template>
</gl-sprintf>
</li>
<li>
<gl-sprintf :message="n__('%d star', '%d stars', starsCount)">
<template #starsCount>{{ starsCount }}</template>
</gl-sprintf>
</li>
</ul>
<gl-sprintf :message="$options.strings.alertBody">
<template #strong="{ content }">
<strong>{{ content }}</strong>

View File

@ -1,4 +1,5 @@
import Vue from 'vue';
import { parseBoolean } from '~/lib/utils/common_utils';
import ProjectDeleteButton from './components/project_delete_button.vue';
export default (selector = '#js-project-delete-button') => {
@ -6,7 +7,15 @@ export default (selector = '#js-project-delete-button') => {
if (!el) return;
const { confirmPhrase, formPath } = el.dataset;
const {
confirmPhrase,
formPath,
isFork,
issuesCount,
mergeRequestsCount,
forksCount,
starsCount,
} = el.dataset;
// eslint-disable-next-line no-new
new Vue({
@ -16,6 +25,11 @@ export default (selector = '#js-project-delete-button') => {
props: {
confirmPhrase,
formPath,
isFork: parseBoolean(isFork),
issuesCount: parseInt(issuesCount, 10),
mergeRequestsCount: parseInt(mergeRequestsCount, 10),
forksCount: parseInt(forksCount, 10),
starsCount: parseInt(starsCount, 10),
},
});
},

View File

@ -1,13 +1,17 @@
# frozen_string_literal: true
class JwksController < ActionController::Base # rubocop:disable Rails/ApplicationController
class JwksController < Doorkeeper::OpenidConnect::DiscoveryController
def index
render json: { keys: keys }
render json: { keys: payload }
end
def keys
index
end
private
def keys
def payload
[
# We keep openid_connect_signing_key so that we can seamlessly
# replace it with ci_jwt_signing_key and remove it on the next release.

View File

@ -0,0 +1,15 @@
# frozen_string_literal: true
module Projects
# Service class for counting and caching the number of all issues of a
# project.
class AllIssuesCountService < Projects::CountService
def relation_for_count
@project.issues
end
def cache_key_name
'all_issues_count'
end
end
end

View File

@ -0,0 +1,15 @@
# frozen_string_literal: true
module Projects
# Service class for counting and caching the number of all merge requests of
# a project.
class AllMergeRequestsCountService < Projects::CountService
def relation_for_count
@project.merge_requests
end
def cache_key_name
'all_merge_requests_count'
end
end
end

View File

@ -1,4 +1,4 @@
- breadcrumb_title _('Customer Relations Contacts')
- page_title _('Customer Relations Contacts')
#js-crm-contacts-app
#js-crm-contacts-app{ data: { group_full_path: @group.full_path } }

View File

@ -1,4 +1,6 @@
- return unless can?(current_user, :remove_project, project)
- merge_requests_count = Projects::AllMergeRequestsCountService.new(project).count
- issues_count = Projects::AllIssuesCountService.new(project).count
.sub-section
%h4.danger-title= _('Delete project')
@ -7,4 +9,4 @@
= link_to _('Learn more.'), help_page_path('user/project/settings/index', anchor: 'removing-a-fork-relationship'), target: '_blank', rel: 'noopener noreferrer'
%p
%strong= _('Deleted projects cannot be restored!')
#js-project-delete-button{ data: { form_path: project_path(project), confirm_phrase: delete_confirm_phrase(project) } }
#js-project-delete-button{ data: { form_path: project_path(project), confirm_phrase: delete_confirm_phrase(project), is_fork: project.forked?.to_s, issues_count: number_with_delimiter(issues_count), merge_requests_count: number_with_delimiter(merge_requests_count), forks_count: number_with_delimiter(project.forks_count), stars_count: number_with_delimiter(project.star_count) } }

View File

@ -45,6 +45,23 @@ Gitlab.ee do
end
end
### Modified from elasticsearch-model/lib/elasticsearch/model/searching.rb
module Elasticsearch
module Model
module Searching
class SearchRequest
def execute!
response = klass.client.search(@definition)
raise Elastic::TimeoutError if response['timed_out']
response
end
end
end
end
end
### Modified from elasticsearch-model/lib/elasticsearch/model.rb
[

View File

@ -43,12 +43,15 @@ Rails.application.routes.draw do
draw :oauth
use_doorkeeper_openid_connect
use_doorkeeper_openid_connect do
controllers discovery: 'jwks'
end
# Add OPTIONS method for CORS preflight requests
match '/oauth/userinfo' => 'doorkeeper/openid_connect/userinfo#show', via: :options
match '/oauth/discovery/keys' => 'doorkeeper/openid_connect/discovery#keys', via: :options
match '/.well-known/openid-configuration' => 'doorkeeper/openid_connect/discovery#provider', via: :options
match '/.well-known/webfinger' => 'doorkeeper/openid_connect/discovery#webfinger', via: :options
match '/oauth/discovery/keys' => 'jwks#keys', via: :options
match '/.well-known/openid-configuration' => 'jwks#provider', via: :options
match '/.well-known/webfinger' => 'jwks#webfinger', via: :options
match '/oauth/token' => 'oauth/tokens#create', via: :options
match '/oauth/revoke' => 'oauth/tokens#revoke', via: :options

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +0,0 @@
# frozen_string_literal: true
class AddExpandedEnvironmentNameToCiBuildMetadata < ActiveRecord::Migration[5.2]
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def up
add_column :ci_builds_metadata, :expanded_environment_name, :string, limit: 255
end
# rubocop:enable Migration/PreventStrings
def down
remove_column :ci_builds_metadata, :expanded_environment_name
end
end

View File

@ -1,17 +0,0 @@
# frozen_string_literal: true
class AddStorageVersionIndexToProjects < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :projects, :id, where: 'storage_version < 2 or storage_version IS NULL', name: 'index_on_id_partial_with_legacy_storage'
end
def down
remove_concurrent_index :projects, :id, where: 'storage_version < 2 or storage_version IS NULL', name: 'index_on_id_partial_with_legacy_storage'
end
end

View File

@ -1,12 +0,0 @@
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class AddColumnForInstanceAdministratorsGroup < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column :application_settings, :instance_administrators_group_id, :integer
end
end

View File

@ -1,22 +0,0 @@
# frozen_string_literal: true
class AddFkForInstanceAdministratorsGroup < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_foreign_key(
:application_settings,
:namespaces,
column: :instance_administrators_group_id,
on_delete: :nullify
)
end
def down
remove_foreign_key :application_settings, column: :instance_administrators_group_id
end
end

View File

@ -1,17 +0,0 @@
# frozen_string_literal: true
class AddIndexForInstanceAdministratorsGroup < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :application_settings, :instance_administrators_group_id
end
def down
remove_concurrent_index :application_settings, :instance_administrators_group_id
end
end

View File

@ -1,9 +0,0 @@
# frozen_string_literal: true
class AddAutocloseReferencedIssuesToProjects < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column :projects, :autoclose_referenced_issues, :boolean # rubocop:disable Migration/AddColumnsToWideTables
end
end

View File

@ -1,9 +0,0 @@
# frozen_string_literal: true
class AddForkingAccessLevelToProjectFeature < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column :project_features, :forking_access_level, :integer
end
end

View File

@ -1,23 +0,0 @@
# frozen_string_literal: true
class AddTimestampsToPackagesTags < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
# We disable these cops here because adding this column is safe. The table does not
# have any data in it.
# rubocop: disable Migration/AddIndex
def up
add_timestamps_with_timezone(:packages_tags, null: false)
add_index(:packages_tags, [:package_id, :updated_at], order: { updated_at: :desc })
end
# We disable these cops here because adding this column is safe. The table does not
# have any data in it.
# rubocop: disable Migration/RemoveIndex
def down
remove_index(:packages_tags, [:package_id, :updated_at])
remove_timestamps(:packages_tags)
end
end

View File

@ -1,15 +0,0 @@
# frozen_string_literal: true
class AddTimestampSoftwarelicensespolicy < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
add_timestamps_with_timezone(:software_license_policies, null: true)
end
def down
remove_timestamps(:software_license_policies)
end
end

View File

@ -1,23 +0,0 @@
# frozen_string_literal: true
class UpdateProjectHooksLimit < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
return unless Gitlab.com?
create_or_update_plan_limit('project_hooks', 'free', 100)
create_or_update_plan_limit('project_hooks', 'bronze', 100)
create_or_update_plan_limit('project_hooks', 'silver', 100)
end
def down
return unless Gitlab.com?
create_or_update_plan_limit('project_hooks', 'free', 10)
create_or_update_plan_limit('project_hooks', 'bronze', 20)
create_or_update_plan_limit('project_hooks', 'silver', 30)
end
end

View File

@ -1,21 +0,0 @@
# frozen_string_literal: true
class CreateIndexesForProjectApiCreatedAtOrder < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :projects, %i(visibility_level created_at id), order: { id: :desc }, name: 'index_projects_on_visibility_level_created_at_id_desc'
add_concurrent_index :projects, %i(visibility_level created_at id), order: { created_at: :desc, id: :desc }, name: 'index_projects_on_visibility_level_created_at_desc_id_desc'
remove_concurrent_index_by_name :projects, 'index_projects_on_visibility_level_and_created_at_and_id'
end
def down
add_concurrent_index :projects, %i(visibility_level created_at id), name: 'index_projects_on_visibility_level_and_created_at_and_id'
remove_concurrent_index_by_name :projects, 'index_projects_on_visibility_level_created_at_id_desc'
remove_concurrent_index_by_name :projects, 'index_projects_on_visibility_level_created_at_desc_id_desc'
end
end

View File

@ -1,17 +0,0 @@
# frozen_string_literal: true
class RemoveIndexProjectMirrorDataOnJid < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
remove_concurrent_index :project_mirror_data, :jid
end
def down
add_concurrent_index :project_mirror_data, :jid
end
end

View File

@ -1,21 +0,0 @@
# frozen_string_literal: true
class AddSortingIndexToPackages < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :packages_packages, [:project_id, :created_at]
add_concurrent_index :packages_packages, [:project_id, :version]
add_concurrent_index :packages_packages, [:project_id, :package_type]
end
def down
remove_concurrent_index :packages_packages, [:project_id, :created_at]
remove_concurrent_index :packages_packages, [:project_id, :version]
remove_concurrent_index :packages_packages, [:project_id, :package_type]
end
end

View File

@ -1,19 +0,0 @@
# frozen_string_literal: true
class CreateApprovalProjectRulesProtectedBranches < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
create_table :approval_project_rules_protected_branches, id: false do |t|
t.references :approval_project_rule,
null: false,
index: false,
foreign_key: { on_delete: :cascade }
t.references :protected_branch,
null: false,
index: { name: 'index_approval_project_rules_protected_branches_pb_id' },
foreign_key: { on_delete: :cascade }
t.index [:approval_project_rule_id, :protected_branch_id], name: 'index_approval_project_rules_protected_branches_unique', unique: true, using: :btree
end
end
end

View File

@ -1,17 +0,0 @@
# frozen_string_literal: true
class RemoveProjectIdIndexFromPackages < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
remove_concurrent_index :packages_packages, [:project_id]
end
def down
add_concurrent_index :packages_packages, [:project_id]
end
end

View File

@ -1,24 +0,0 @@
# frozen_string_literal: true
class FixInvalidEpicSourcingMilestoneIds < ActiveRecord::Migration[5.2]
DOWNTIME = false
def up
nullify_invalid_data(:start_date_sourcing_milestone_id)
nullify_invalid_data(:due_date_sourcing_milestone_id)
end
def down
# no-op
end
private
def nullify_invalid_data(column_name)
execute(<<-SQL.squish)
UPDATE epics
SET #{column_name} = null
WHERE #{column_name} NOT IN (SELECT id FROM milestones);
SQL
end
end

View File

@ -1,15 +0,0 @@
# frozen_string_literal: true
class ValidateForeignKeyEpicStartDateSourcingMilestone < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
validate_foreign_key(:epics, :start_date_sourcing_milestone_id)
end
def down
# no-op
end
end

View File

@ -1,31 +0,0 @@
# frozen_string_literal: true
class AddIndexesForProjectsApi < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
COLUMNS = %i(created_at last_activity_at updated_at name path)
def up
COLUMNS.each do |column|
add_concurrent_index :projects, [column, :id], where: 'visibility_level = 20', order: { id: :desc }, name: "index_projects_api_vis20_#{column}_id_desc"
add_concurrent_index :projects, [column, :id], where: 'visibility_level = 20', name: "index_projects_api_vis20_#{column}"
end
remove_concurrent_index_by_name :projects, 'index_projects_on_visibility_level_created_at_id_desc'
remove_concurrent_index_by_name :projects, 'index_projects_on_visibility_level_created_at_desc_id_desc'
end
def down
add_concurrent_index :projects, %i(visibility_level created_at id), order: { id: :desc }, name: 'index_projects_on_visibility_level_created_at_id_desc'
add_concurrent_index :projects, %i(visibility_level created_at id), order: { created_at: :desc, id: :desc }, name: 'index_projects_on_visibility_level_created_at_desc_id_desc'
COLUMNS.each do |column|
remove_concurrent_index_by_name :projects, "index_projects_api_vis20_#{column}_id_desc"
remove_concurrent_index_by_name :projects, "index_projects_api_vis20_#{column}"
end
end
end

View File

@ -1,15 +0,0 @@
# frozen_string_literal: true
class ValidateForeignKeyEpicDueDateSourcingMilestone < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
validate_foreign_key(:epics, :due_date_sourcing_milestone_id)
end
def down
# no-op
end
end

View File

@ -1,45 +0,0 @@
# frozen_string_literal: true
class AddIndexesForProjectsApiAuthenticated < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
COLUMNS = %i(updated_at name)
def up
add_concurrent_index :projects, %i(created_at id), order: { id: :desc }, name: 'index_projects_api_created_at_id_desc'
add_concurrent_index :projects, %i(last_activity_at id), name: 'index_projects_on_last_activity_at_and_id'
remove_concurrent_index :projects, :last_activity_at
add_concurrent_index :projects, %i(last_activity_at id), order: { id: :desc }, name: 'index_projects_api_last_activity_at_id_desc'
add_concurrent_index :projects, %i(path id), name: 'index_projects_on_path_and_id'
remove_concurrent_index_by_name :projects, 'index_projects_on_path'
add_concurrent_index :projects, %i(path id), order: { id: :desc }, name: 'index_projects_api_path_id_desc'
COLUMNS.each do |column|
add_concurrent_index :projects, [column, :id], name: "index_projects_on_#{column}_and_id"
add_concurrent_index :projects, [column, :id], order: { id: :desc }, name: "index_projects_api_#{column}_id_desc"
end
end
def down
remove_concurrent_index_by_name :projects, 'index_projects_api_created_at_id_desc'
remove_concurrent_index_by_name :projects, 'index_projects_on_last_activity_at_and_id'
add_concurrent_index :projects, :last_activity_at, name: 'index_projects_on_last_activity_at'
remove_concurrent_index_by_name :projects, 'index_projects_api_last_activity_at_id_desc'
remove_concurrent_index_by_name :projects, 'index_projects_on_path_and_id'
add_concurrent_index :projects, :path, name: 'index_projects_on_path'
remove_concurrent_index_by_name :projects, 'index_projects_api_path_id_desc'
COLUMNS.each do |column|
remove_concurrent_index_by_name :projects, "index_projects_on_#{column}_and_id"
remove_concurrent_index_by_name :projects, "index_projects_api_#{column}_id_desc"
end
end
end

View File

@ -1,29 +0,0 @@
# frozen_string_literal: true
class AddFieldsToApplicationSettingsForMergeRequestsApprovals < ActiveRecord::Migration[5.2]
DOWNTIME = false
def up
add_column(:application_settings,
:disable_overriding_approvers_per_merge_request,
:boolean,
default: false,
null: false)
add_column(:application_settings,
:prevent_merge_requests_author_approval,
:boolean,
default: false,
null: false)
add_column(:application_settings,
:prevent_merge_requests_committers_approval,
:boolean,
default: false,
null: false)
end
def down
remove_column(:application_settings, :disable_overriding_approvers_per_merge_request)
remove_column(:application_settings, :prevent_merge_requests_author_approval)
remove_column(:application_settings, :prevent_merge_requests_committers_approval)
end
end

View File

@ -1,17 +0,0 @@
# frozen_string_literal: true
class AddIndexToSentryIssuesSentryIssueIdentifier < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :sentry_issues, :sentry_issue_identifier
end
def down
remove_concurrent_index :sentry_issues, :sentry_issue_identifier
end
end

View File

@ -1,11 +0,0 @@
# frozen_string_literal: true
class AddRetryCountAndGroupIdToImportFailures < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column :import_failures, :retry_count, :integer
add_column :import_failures, :group_id, :integer
change_column_null(:import_failures, :project_id, true)
end
end

View File

@ -1,22 +0,0 @@
# frozen_string_literal: true
class AddGroupIndexAndFkToImportFailures < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
GROUP_INDEX = 'index_import_failures_on_group_id_not_null'
disable_ddl_transaction!
def up
add_concurrent_index(:import_failures, :group_id, where: 'group_id IS NOT NULL', name: GROUP_INDEX)
add_concurrent_foreign_key(:import_failures, :namespaces, column: :group_id)
end
def down
remove_foreign_key(:import_failures, column: :group_id)
remove_concurrent_index_by_name(:import_failures, GROUP_INDEX)
end
end

View File

@ -1,18 +0,0 @@
# frozen_string_literal: true
class DropBackgroundMigrationJobs < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
DROPPED_JOB_CLASS = 'ActivatePrometheusServicesForSharedClusterApplications'
QUEUE = 'background_migration'
def up
Sidekiq::Queue.new(QUEUE).each do |job|
klass, project_id, *should_be_empty = job.args
next unless klass == DROPPED_JOB_CLASS && project_id.is_a?(Integer) && should_be_empty.empty?
job.delete
end
end
end

View File

@ -1,28 +0,0 @@
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class UpdateTimestampSoftwarelicensespolicy < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
time = Time.zone.now
update_column_in_batches(:software_license_policies, :created_at, time) do |table, query|
query.where(table[:created_at].eq(nil))
end
update_column_in_batches(:software_license_policies, :updated_at, time) do |table, query|
query.where(table[:updated_at].eq(nil))
end
end
def down
# no-op
end
end

View File

@ -1,22 +0,0 @@
# frozen_string_literal: true
class UpdateProjectIndexToImportFailures < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
PROJECT_INDEX_OLD = 'index_import_failures_on_project_id'
PROJECT_INDEX_NEW = 'index_import_failures_on_project_id_not_null'
disable_ddl_transaction!
def up
add_concurrent_index(:import_failures, :project_id, where: 'project_id IS NOT NULL', name: PROJECT_INDEX_NEW)
remove_concurrent_index_by_name(:import_failures, PROJECT_INDEX_OLD)
end
def down
add_concurrent_index(:import_failures, :project_id, name: PROJECT_INDEX_OLD)
remove_concurrent_index_by_name(:import_failures, PROJECT_INDEX_NEW)
end
end

View File

@ -1,13 +0,0 @@
# frozen_string_literal: true
class AddIidToOperationsFeatureFlags < ActiveRecord::Migration[5.2]
DOWNTIME = false
def up
add_column :operations_feature_flags, :iid, :integer
end
def down
remove_column :operations_feature_flags, :iid
end
end

View File

@ -1,17 +0,0 @@
# frozen_string_literal: true
class AddIndexOnOperationsFeatureFlagsIid < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :operations_feature_flags, [:project_id, :iid], unique: true
end
def down
remove_concurrent_index :operations_feature_flags, [:project_id, :iid]
end
end

View File

@ -1,15 +0,0 @@
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class UpdateTimestampSoftwarelicensespolicyNotNull < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
change_column_null(:software_license_policies, :created_at, false)
change_column_null(:software_license_policies, :updated_at, false)
end
end

View File

@ -1,16 +0,0 @@
# frozen_string_literal: true
class CreateGeoEvents < ActiveRecord::Migration[5.2]
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change
create_table :geo_events do |t|
t.string :replicable_name, limit: 255, null: false
t.string :event_name, limit: 255, null: false
t.jsonb :payload, default: {}, null: false
t.datetime_with_timezone :created_at, null: false
end
end
# rubocop:enable Migration/PreventStrings
end

View File

@ -1,9 +0,0 @@
# frozen_string_literal: true
class AddGeoEventIdToGeoEventLog < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column :geo_event_log, :geo_event_id, :integer
end
end

View File

@ -1,20 +0,0 @@
# frozen_string_literal: true
class AddGeoEventIdIndexToGeoEventLog < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :geo_event_log, :geo_event_id,
where: "(geo_event_id IS NOT NULL)",
using: :btree,
name: 'index_geo_event_log_on_geo_event_id'
end
def down
remove_concurrent_index :geo_event_log, :geo_event_id, name: 'index_geo_event_log_on_geo_event_id'
end
end

View File

@ -1,20 +0,0 @@
# frozen_string_literal: true
class AddGeoEventsForeignKey < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_foreign_key :geo_event_log, :geo_events,
column: :geo_event_id,
name: 'fk_geo_event_log_on_geo_event_id',
on_delete: :cascade
end
def down
remove_foreign_key_without_error :geo_event_log, column: :geo_event_id, name: 'fk_geo_event_log_on_geo_event_id'
end
end

View File

@ -1,16 +0,0 @@
# frozen_string_literal: true
class CreateGroupDeployTokens < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
create_table :group_deploy_tokens do |t|
t.timestamps_with_timezone null: false
t.references :group, index: false, null: false, foreign_key: { to_table: :namespaces, on_delete: :cascade }
t.references :deploy_token, null: false, foreign_key: { on_delete: :cascade }
t.index [:group_id, :deploy_token_id], unique: true, name: 'index_group_deploy_tokens_on_group_and_deploy_token_ids'
end
end
end

View File

@ -1,17 +0,0 @@
# frozen_string_literal: true
class AddDeployTokenTypeToDeployTokens < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
DOWNTIME = false
def up
add_column_with_default :deploy_tokens, :deploy_token_type, :integer, default: 2, limit: 2, allow_null: false # rubocop:disable Migration/AddColumnWithDefault
end
def down
remove_column :deploy_tokens, :deploy_token_type
end
end

View File

@ -1,17 +0,0 @@
# frozen_string_literal: true
class AddMultiColumnIndexOnLfsObjectsProjects < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :lfs_objects_projects, [:project_id, :lfs_object_id]
end
def down
remove_concurrent_index :lfs_objects_projects, [:project_id, :lfs_object_id]
end
end

View File

@ -1,17 +0,0 @@
# frozen_string_literal: true
class RemoveProjectIdIndexOnLfsObjectsProjects < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
remove_concurrent_index :lfs_objects_projects, :project_id
end
def down
add_concurrent_index :lfs_objects_projects, :project_id
end
end

View File

@ -1,30 +0,0 @@
# frozen_string_literal: true
class RemoveAnalyticsRepositoryTableFksOnProjects < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
# Requires ExclusiveLock on all tables. analytics_* tables are empty
with_lock_retries do
remove_foreign_key_if_exists(:analytics_repository_files, :projects)
end
with_lock_retries do
remove_foreign_key_if_exists(:analytics_repository_file_edits, :projects) if table_exists?(:analytics_repository_file_edits) # this table might be already dropped on development environment
end
with_lock_retries do
remove_foreign_key_if_exists(:analytics_repository_file_commits, :projects)
end
end
def down
add_concurrent_foreign_key(:analytics_repository_files, :projects, column: :project_id, on_delete: :cascade)
add_concurrent_foreign_key(:analytics_repository_file_edits, :projects, column: :project_id, on_delete: :cascade)
add_concurrent_foreign_key(:analytics_repository_file_commits, :projects, column: :project_id, on_delete: :cascade)
end
end

View File

@ -1,25 +0,0 @@
# frozen_string_literal: true
class RemoveAnalyticsRepositoryFilesFkOnOtherAnalyticsTables < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
# Requires ExclusiveLock on all tables. analytics_* tables are empty
with_lock_retries do
remove_foreign_key_if_exists(:analytics_repository_file_edits, :analytics_repository_files) if table_exists?(:analytics_repository_file_edits) # this table might be already dropped on development environment
end
with_lock_retries do
remove_foreign_key_if_exists(:analytics_repository_file_commits, :analytics_repository_files)
end
end
def down
add_concurrent_foreign_key(:analytics_repository_file_edits, :analytics_repository_files, column: :analytics_repository_file_id, on_delete: :cascade)
add_concurrent_foreign_key(:analytics_repository_file_commits, :analytics_repository_files, column: :analytics_repository_file_id, on_delete: :cascade)
end
end

View File

@ -1,23 +0,0 @@
# frozen_string_literal: true
class DropAnalyticsRepositoryFilesTable < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
# Requires ExclusiveLock on the table. Not in use, no records, no FKs.
# rubocop:disable Migration/DropTable
drop_table :analytics_repository_files
# rubocop:enable Migration/DropTable
end
def down
create_table :analytics_repository_files do |t|
t.bigint :project_id, null: false
t.string :file_path, limit: 4096, null: false
end
add_index :analytics_repository_files, [:project_id, :file_path], unique: true
end
end

View File

@ -1,29 +0,0 @@
# frozen_string_literal: true
class DropAnalyticsRepositoryFileCommitsTable < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
# Requires ExclusiveLock on the table. Not in use, no records, no FKs.
# rubocop:disable Migration/DropTable
drop_table :analytics_repository_file_commits
# rubocop:enable Migration/DropTable
end
def down
create_table :analytics_repository_file_commits do |t|
t.bigint :analytics_repository_file_id, null: false
t.index :analytics_repository_file_id, name: 'index_analytics_repository_file_commits_file_id'
t.bigint :project_id, null: false
t.date :committed_date, null: false
t.integer :commit_count, limit: 2, null: false
end
add_index :analytics_repository_file_commits,
[:project_id, :committed_date, :analytics_repository_file_id],
name: 'index_file_commits_on_committed_date_file_id_and_project_id',
unique: true
end
end

View File

@ -1,29 +0,0 @@
# frozen_string_literal: true
class DropAnalyticsRepositoryFileEditsTable < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
# Requires ExclusiveLock on the table. Not in use, no records, no FKs.
# rubocop:disable Migration/DropTable
drop_table :analytics_repository_file_edits if table_exists?(:analytics_repository_file_edits) # this table might be already dropped on development environment
# rubocop:enable Migration/DropTable
end
def down
create_table :analytics_repository_file_edits do |t|
t.bigint :project_id, null: false
t.index :project_id
t.bigint :analytics_repository_file_id, null: false
t.date :committed_date, null: false
t.integer :num_edits, null: false, default: 0
end
add_index :analytics_repository_file_edits,
[:analytics_repository_file_id, :committed_date, :project_id],
name: 'index_file_edits_on_committed_date_file_id_and_project_id',
unique: true
end
end

View File

@ -1,11 +0,0 @@
# frozen_string_literal: true
class AddSourceToImportFailures < ActiveRecord::Migration[5.2]
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change
add_column :import_failures, :source, :string, limit: 128
end
# rubocop:enable Migration/PreventStrings
end

View File

@ -1,9 +0,0 @@
# frozen_string_literal: true
class AddRestrictDeploymentOrderToProjectCiCdSettings < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column :project_ci_cd_settings, :forward_deployment_enabled, :boolean
end
end

View File

@ -1,10 +0,0 @@
# frozen_string_literal: true
class AddDurationToMergeTrains < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column :merge_trains, :merged_at, :datetime_with_timezone
add_column :merge_trains, :duration, :integer
end
end

View File

@ -1,17 +0,0 @@
# frozen_string_literal: true
class AddIndexWebHooksOnGroupId < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :web_hooks, :group_id, where: "type = 'GroupHook'"
end
def down
remove_concurrent_index :web_hooks, :group_id, where: "type = 'GroupHook'"
end
end

View File

@ -1,18 +0,0 @@
# frozen_string_literal: true
class AddUsageToPagesDomains < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
PAGES_USAGE = 0
disable_ddl_transaction!
def up
add_column_with_default :pages_domains, :usage, :integer, limit: 2, default: PAGES_USAGE, allow_null: false # rubocop:disable Migration/AddColumnWithDefault
end
def down
remove_column :pages_domains, :usage
end
end

View File

@ -1,21 +0,0 @@
# frozen_string_literal: true
class UpdateIndexesOfPagesDomainsAddUsageDomainWildcardRemoveDomain < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :pages_domains, :usage
add_concurrent_index :pages_domains, [:domain, :wildcard], unique: true
remove_concurrent_index :pages_domains, :domain
end
def down
remove_concurrent_index :pages_domains, :usage
remove_concurrent_index :pages_domains, [:domain, :wildcard]
add_concurrent_index :pages_domains, :domain, unique: true
end
end

View File

@ -1,17 +0,0 @@
# frozen_string_literal: true
class RenamePagesDomainsDomainTypeToScope < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
rename_column_concurrently :pages_domains, :domain_type, :scope
end
def down
undo_rename_column_concurrently :pages_domains, :domain_type, :scope
end
end

View File

@ -1,27 +0,0 @@
# frozen_string_literal: true
class AddResourceMilestoneEventsTable < ActiveRecord::Migration[5.2]
DOWNTIME = false
# rubocop:disable Migration/AddLimitToTextColumns
def change
create_table :resource_milestone_events, id: :bigserial do |t|
t.references :user, null: false, foreign_key: { on_delete: :nullify },
index: { name: 'index_resource_milestone_events_on_user_id' }
t.references :issue, null: true, foreign_key: { on_delete: :cascade },
index: { name: 'index_resource_milestone_events_on_issue_id' }
t.references :merge_request, null: true, foreign_key: { on_delete: :cascade },
index: { name: 'index_resource_milestone_events_on_merge_request_id' }
t.references :milestone, foreign_key: { on_delete: :cascade },
index: { name: 'index_resource_milestone_events_on_milestone_id' }
t.integer :action, limit: 2, null: false
t.integer :state, limit: 2, null: false
t.integer :cached_markdown_version
t.text :reference
t.text :reference_html
t.datetime_with_timezone :created_at, null: false
end
end
# rubocop:enable Migration/AddLimitToTextColumns
end

View File

@ -1,24 +0,0 @@
# frozen_string_literal: true
class AddIndexOnAuditEventsIdDesc < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
OLD_INDEX_NAME = 'index_audit_events_on_entity_id_and_entity_type'
NEW_INDEX_NAME = 'index_audit_events_on_entity_id_and_entity_type_and_id_desc'
disable_ddl_transaction!
def up
add_concurrent_index :audit_events, [:entity_id, :entity_type, :id], name: NEW_INDEX_NAME,
order: { entity_id: :asc, entity_type: :asc, id: :desc }
remove_concurrent_index_by_name :audit_events, OLD_INDEX_NAME
end
def down
add_concurrent_index :audit_events, [:entity_id, :entity_type], name: OLD_INDEX_NAME
remove_concurrent_index_by_name :audit_events, NEW_INDEX_NAME
end
end

View File

@ -1,17 +0,0 @@
# frozen_string_literal: true
class AddCertAndKeyToServerlessDomainCluster < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
# rubocop:disable Migration/AddLimitToTextColumns
def change
add_column :serverless_domain_cluster, :encrypted_key, :text
add_column :serverless_domain_cluster, :encrypted_key_iv, :string, limit: 255
add_column :serverless_domain_cluster, :certificate, :text
end
# rubocop:enable Migration/AddLimitToTextColumns
# rubocop:enable Migration/PreventStrings
end

View File

@ -1,31 +0,0 @@
# frozen_string_literal: true
class DropUnneededIndexesForProjectsApiRequests < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
DOWNTIME = false
def up
indexes = %w(
index_projects_api_vis20_created_at_id_desc
index_projects_api_vis20_last_activity_at_id_desc
index_projects_api_vis20_updated_at_id_desc
index_projects_api_vis20_name_id_desc
index_projects_api_vis20_path_id_desc
)
indexes.each do |index|
remove_concurrent_index_by_name :projects, index
end
end
def down
columns = %i(created_at last_activity_at updated_at name path)
columns.each do |column|
add_concurrent_index :projects, [column, :id], where: 'visibility_level = 20', order: { id: :desc }, name: "index_projects_api_vis20_#{column}_id_desc"
end
end
end

View File

@ -1,17 +0,0 @@
# frozen_string_literal: true
class CreateIndexOnAutoStopIn < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :environments, %i[state auto_stop_at], where: "auto_stop_at IS NOT NULL AND state = 'available'"
end
def down
remove_concurrent_index :environments, %i[state auto_stop_at]
end
end

View File

@ -1,9 +0,0 @@
# frozen_string_literal: true
class AddHealthStatusToEpics < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :epics, :health_status, :integer, limit: 2
end
end

View File

@ -1,9 +0,0 @@
# frozen_string_literal: true
class AddHealthStatusToIssues < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :issues, :health_status, :integer, limit: 2
end
end

View File

@ -1,11 +0,0 @@
# frozen_string_literal: true
class AddServiceDeskProjectKey < ActiveRecord::Migration[5.2]
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change
add_column :service_desk_settings, :project_key, :string, limit: 255
end
# rubocop:enable Migration/PreventStrings
end

View File

@ -1,9 +0,0 @@
# frozen_string_literal: true
class AddIdToDesignManagementDesignsVersions < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :design_management_designs_versions, :id, :primary_key
end
end

View File

@ -1,23 +0,0 @@
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class DefaultLockVersionToZeroForMergeRequests < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def up
with_lock_retries do
change_column_default :merge_requests, :lock_version, from: nil, to: 0
end
end
def down
with_lock_retries do
change_column_default :merge_requests, :lock_version, from: 0, to: nil
end
end
end

View File

@ -1,23 +0,0 @@
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class DefaultLockVersionToZeroForIssues < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def up
with_lock_retries do
change_column_default :issues, :lock_version, from: nil, to: 0
end
end
def down
with_lock_retries do
change_column_default :issues, :lock_version, from: 0, to: nil
end
end
end

View File

@ -1,23 +0,0 @@
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class DefaultLockVersionToZeroForEpics < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def up
with_lock_retries do
change_column_default :epics, :lock_version, from: nil, to: 0
end
end
def down
with_lock_retries do
change_column_default :epics, :lock_version, from: 0, to: nil
end
end
end

View File

@ -1,23 +0,0 @@
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class DefaultLockVersionToZeroForCiBuilds < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def up
with_lock_retries do
change_column_default :ci_builds, :lock_version, from: nil, to: 0
end
end
def down
with_lock_retries do
change_column_default :ci_builds, :lock_version, from: 0, to: nil
end
end
end

View File

@ -1,23 +0,0 @@
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class DefaultLockVersionToZeroForCiStages < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def up
with_lock_retries do
change_column_default :ci_stages, :lock_version, from: nil, to: 0
end
end
def down
with_lock_retries do
change_column_default :ci_stages, :lock_version, from: 0, to: nil
end
end
end

View File

@ -1,23 +0,0 @@
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class DefaultLockVersionToZeroForCiPipelines < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def up
with_lock_retries do
change_column_default :ci_pipelines, :lock_version, from: nil, to: 0
end
end
def down
with_lock_retries do
change_column_default :ci_pipelines, :lock_version, from: 0, to: nil
end
end
end

View File

@ -1,10 +0,0 @@
# frozen_string_literal: true
class AddConfirmedAttributesToVulnerabilities < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column :vulnerabilities, :confirmed_by_id, :bigint
add_column :vulnerabilities, :confirmed_at, :datetime_with_timezone
end
end

View File

@ -1,19 +0,0 @@
# frozen_string_literal: true
class AddIndexForVulnerabilityConfirmedBy < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :vulnerabilities, :confirmed_by_id
add_concurrent_foreign_key :vulnerabilities, :users, column: :confirmed_by_id, on_delete: :nullify
end
def down
remove_foreign_key :vulnerabilities, column: :confirmed_by_id
remove_concurrent_index :vulnerabilities, :confirmed_by_id
end
end

View File

@ -1,24 +0,0 @@
# frozen_string_literal: true
class CreateSecurityScan < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
create_table :security_scans, id: :bigserial do |t|
t.timestamps_with_timezone null: false
t.references :build,
null: false,
index: false,
foreign_key: { to_table: :ci_builds, on_delete: :cascade },
type: :bigint
t.integer :scan_type,
null: false,
index: { name: "idx_security_scans_on_scan_type" },
limit: 2
t.index [:build_id, :scan_type], name: "idx_security_scans_on_build_and_scan_type", unique: true
end
end
end

View File

@ -1,17 +0,0 @@
# frozen_string_literal: true
class AddElasticsearchIndexedFieldLengthLimitToApplicationSettings < ActiveRecord::Migration[6.0]
DOWNTIME = false
def up
add_column :application_settings, :elasticsearch_indexed_field_length_limit, :integer, null: false, default: 0
if Gitlab.com?
execute 'UPDATE application_settings SET elasticsearch_indexed_field_length_limit = 20000'
end
end
def down
remove_column :application_settings, :elasticsearch_indexed_field_length_limit
end
end

View File

@ -1,19 +0,0 @@
# frozen_string_literal: true
class ChangeBroadcastMessageIndex < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :broadcast_messages, %i(ends_at broadcast_type id), name: 'index_broadcast_message_on_ends_at_and_broadcast_type_and_id'
remove_concurrent_index_by_name :broadcast_messages, :index_broadcast_messages_on_starts_at_and_ends_at_and_id
end
def down
add_concurrent_index :broadcast_messages, %i(starts_at ends_at id), name: 'index_broadcast_messages_on_starts_at_and_ends_at_and_id'
remove_concurrent_index_by_name :broadcast_messages, :index_broadcast_message_on_ends_at_and_broadcast_type_and_id
end
end

View File

@ -1,24 +0,0 @@
# frozen_string_literal: true
class CreateDailyReportResults < ActiveRecord::Migration[6.0]
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change
create_table :ci_daily_report_results do |t|
t.date :date, null: false
t.bigint :project_id, null: false
t.bigint :last_pipeline_id, null: false
t.float :value, null: false
t.integer :param_type, limit: 8, null: false
t.string :ref_path, null: false
t.string :title, null: false
t.index :last_pipeline_id
t.index [:project_id, :ref_path, :param_type, :date, :title], name: 'index_daily_report_results_unique_columns', unique: true
t.foreign_key :projects, on_delete: :cascade
t.foreign_key :ci_pipelines, column: :last_pipeline_id, on_delete: :cascade
end
end
# rubocop:enable Migration/PreventStrings
end

View File

@ -1,9 +0,0 @@
# frozen_string_literal: true
class AddDissmisedAtToUserCallouts < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column :user_callouts, :dismissed_at, :datetime_with_timezone
end
end

View File

@ -1,15 +0,0 @@
# frozen_string_literal: true
class CreateSnippetRepositoryTable < ActiveRecord::Migration[6.0]
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change
create_table :snippet_repositories, id: false, primary_key: :snippet_id do |t|
t.references :shard, null: false, index: true, foreign_key: { on_delete: :restrict }
t.references :snippet, primary_key: true, default: nil, index: false, foreign_key: { on_delete: :cascade }
t.string :disk_path, limit: 80, null: false, index: { unique: true }
end
end
# rubocop:enable Migration/PreventStrings
end

View File

@ -1,15 +0,0 @@
# frozen_string_literal: true
class ChangeSamlProviderOuterForksDefault < ActiveRecord::Migration[6.0]
DOWNTIME = false
def up
change_column_null :saml_providers, :prohibited_outer_forks, false
change_column_default :saml_providers, :prohibited_outer_forks, true
end
def down
change_column_default :saml_providers, :prohibited_outer_forks, false
change_column_null :saml_providers, :prohibited_outer_forks, true
end
end

View File

@ -1,19 +0,0 @@
# frozen_string_literal: true
class AddDefaultBranchProtectionToNamespaces < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
with_lock_retries do
add_column :namespaces, :default_branch_protection, :integer, limit: 2 # rubocop:disable Migration/AddColumnsToWideTables
end
end
def down
with_lock_retries do
remove_column :namespaces, :default_branch_protection
end
end
end

View File

@ -1,18 +0,0 @@
# frozen_string_literal: true
class AddNugetIndexToPackagesPackages < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'index_packages_project_id_name_partial_for_nuget'
disable_ddl_transaction!
def up
add_concurrent_index :packages_packages, [:project_id, :name], name: INDEX_NAME, where: "name <> 'NuGet.Temporary.Package' AND version is not null AND package_type = 4"
end
def down
remove_concurrent_index_by_name :packages_packages, INDEX_NAME
end
end

View File

@ -1,11 +0,0 @@
# frozen_string_literal: true
class AddEsBulkConfig < ActiveRecord::Migration[6.0]
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def change
add_column :application_settings, :elasticsearch_max_bulk_size_mb, :smallint, null: false, default: 10
add_column :application_settings, :elasticsearch_max_bulk_concurrency, :smallint, null: false, default: 10
end
end

View File

@ -1,18 +0,0 @@
# frozen_string_literal: true
class CreateDeploymentClusters < ActiveRecord::Migration[6.0]
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change
create_table :deployment_clusters, id: false, force: :cascade do |t|
t.references :deployment, foreign_key: { on_delete: :cascade }, primary_key: true, type: :integer, index: false, default: nil
t.references :cluster, foreign_key: { on_delete: :cascade }, type: :integer, index: false, null: false
t.string :kubernetes_namespace, limit: 255
t.index [:cluster_id, :kubernetes_namespace], name: 'idx_deployment_clusters_on_cluster_id_and_kubernetes_namespace'
t.index [:cluster_id, :deployment_id], unique: true
end
end
# rubocop:enable Migration/PreventStrings
end

View File

@ -1,25 +0,0 @@
# frozen_string_literal: true
class ReplaceConanMetadataIndex < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
OLD_INDEX = 'index_packages_conan_metadata_on_package_id'
NEW_INDEX = 'index_packages_conan_metadata_on_package_id_username_channel'
disable_ddl_transaction!
def up
add_concurrent_index :packages_conan_metadata,
[:package_id, :package_username, :package_channel],
unique: true, name: NEW_INDEX
remove_concurrent_index_by_name :packages_conan_metadata, OLD_INDEX
end
def down
add_concurrent_index :packages_conan_metadata, :package_id, name: OLD_INDEX
remove_concurrent_index_by_name :packages_conan_metadata, NEW_INDEX
end
end

View File

@ -1,9 +0,0 @@
# frozen_string_literal: true
class AddFeatureFilterTypeToUserPreferences < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :user_preferences, :feature_filter_type, :bigint
end
end

View File

@ -1,13 +0,0 @@
# frozen_string_literal: true
class RemovePackagesDeprecatedDependencies < ActiveRecord::Migration[6.0]
DOWNTIME = false
def up
execute('DELETE FROM packages_dependency_links WHERE dependency_type = 5')
end
def down
# There is nothing to do to reverse this migration
end
end

View File

@ -1,15 +0,0 @@
# frozen_string_literal: true
class CreateOperationsStrategiesTable < ActiveRecord::Migration[6.0]
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change
create_table :operations_strategies do |t|
t.references :feature_flag, index: true, null: false, foreign_key: { to_table: :operations_feature_flags, on_delete: :cascade }
t.string :name, null: false, limit: 255
t.jsonb :parameters, null: false, default: {}
end
end
# rubocop:enable Migration/PreventStrings
end

View File

@ -1,16 +0,0 @@
# frozen_string_literal: true
class CreateOperationsScopesTable < ActiveRecord::Migration[6.0]
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change
create_table :operations_scopes do |t|
t.references :strategy, null: false, index: false, foreign_key: { to_table: :operations_strategies, on_delete: :cascade }
t.string :environment_scope, null: false, limit: 255
end
add_index :operations_scopes, [:strategy_id, :environment_scope], unique: true
end
# rubocop:enable Migration/PreventStrings
end

View File

@ -1,10 +0,0 @@
# frozen_string_literal: true
class AddAutoRenewToGitlabSubscriptions < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :gitlab_subscription_histories, :auto_renew, :boolean
add_column :gitlab_subscriptions, :auto_renew, :boolean
end
end

View File

@ -1,25 +0,0 @@
# frozen_string_literal: true
class RenameSecurityDashboardFeatureFlagToInstanceSecurityDashboard < ActiveRecord::Migration[6.0]
DOWNTIME = false
class FeatureGate < ApplicationRecord
self.table_name = 'feature_gates'
end
def up
security_dashboard_feature = FeatureGate.find_by(feature_key: :security_dashboard, key: :boolean)
if security_dashboard_feature.present?
FeatureGate.safe_find_or_create_by!(
feature_key: :instance_security_dashboard,
key: :boolean,
value: security_dashboard_feature.value
)
end
end
def down
FeatureGate.find_by(feature_key: :instance_security_dashboard, key: :boolean)&.delete
end
end

View File

@ -1,9 +0,0 @@
# frozen_string_literal: true
class AddGroupHooksToPlanLimits < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column(:plan_limits, :group_hooks, :integer, default: 0, null: false)
end
end

View File

@ -1,23 +0,0 @@
# frozen_string_literal: true
class InsertGroupHooksPlanLimits < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
return unless Gitlab.com?
create_or_update_plan_limit('group_hooks', 'bronze', 50)
create_or_update_plan_limit('group_hooks', 'silver', 50)
create_or_update_plan_limit('group_hooks', 'gold', 50)
end
def down
return unless Gitlab.com?
create_or_update_plan_limit('group_hooks', 'bronze', 0)
create_or_update_plan_limit('group_hooks', 'silver', 0)
create_or_update_plan_limit('group_hooks', 'gold', 0)
end
end

Some files were not shown because too many files have changed in this diff Show More