Squash old migrations

- Squash migrations of the year 2019

Changelog: performance

Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/331248
This commit is contained in:
dfrazao-gitlab 2021-09-27 17:44:21 +02:00 committed by Alex Kalderimis
parent 78cce60014
commit 1fe55e57cc
1088 changed files with 11240 additions and 19649 deletions

11226
db/init_structure.sql Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,9 +0,0 @@
# frozen_string_literal: true
class MakeLegacyFalseDefault < ActiveRecord::Migration[5.0]
DOWNTIME = false
def change
change_column_default :cluster_providers_gcp, :legacy_abac, from: true, to: false
end
end

View file

@ -1,34 +0,0 @@
# frozen_string_literal: true
class CleanupLegacyArtifactMigration < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
class Build < ActiveRecord::Base
include EachBatch
self.table_name = 'ci_builds'
self.inheritance_column = :_type_disabled
scope :with_legacy_artifacts, -> { where("artifacts_file <> ''") }
end
def up
Gitlab::BackgroundMigration.steal('MigrateLegacyArtifacts')
CleanupLegacyArtifactMigration::Build
.with_legacy_artifacts
.each_batch(of: 100) do |batch|
range = batch.pluck('MIN(id)', 'MAX(id)').first
Gitlab::BackgroundMigration::MigrateLegacyArtifacts.new.perform(*range)
end
end
def down
# no-op
end
end

View file

@ -1,20 +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 AddServicesTypeIndex < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :services, :type unless index_exists?(:services, :type)
end
def down
remove_concurrent_index :services, :type if index_exists?(:services, :type)
end
end

View file

@ -1,18 +0,0 @@
# frozen_string_literal: true
class RemovePartialIndexFromCiBuildsArtifactsFile < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'partial_index_ci_builds_on_id_with_legacy_artifacts'
disable_ddl_transaction!
def up
remove_concurrent_index_by_name(:ci_builds, INDEX_NAME)
end
def down
add_concurrent_index(:ci_builds, :id, where: "artifacts_file <> ''", name: INDEX_NAME)
end
end

View file

@ -1,25 +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 AddMergeRequestExternalDiffs < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def change
# Allow the merge request diff to store details about an external file
add_column :merge_request_diffs, :external_diff, :string # rubocop:disable Migration/PreventStrings
add_column :merge_request_diffs, :external_diff_store, :integer
add_column :merge_request_diffs, :stored_externally, :boolean
# The diff for each file is mapped to a range in the external file
add_column :merge_request_diff_files, :external_diff_offset, :integer
add_column :merge_request_diff_files, :external_diff_size, :integer
# If the diff is in object storage, it will be null in the database
change_column_null :merge_request_diff_files, :diff, true
end
end

View file

@ -1,9 +0,0 @@
# frozen_string_literal: true
class AddDomainToCluster < ActiveRecord::Migration[5.0]
DOWNTIME = false
def change
add_column :clusters, :domain, :string # rubocop:disable Migration/PreventStrings
end
end

View file

@ -1,11 +0,0 @@
# frozen_string_literal: true
class AddErrorNotificationSentToRemoteMirrors < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :remote_mirrors, :error_notification_sent, :boolean
end
end

View file

@ -1,18 +0,0 @@
# frozen_string_literal: true
class AddColumnsProjectErrorTrackingSettings < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change
add_column :project_error_tracking_settings, :project_name, :string
add_column :project_error_tracking_settings, :organization_name, :string
change_column_default :project_error_tracking_settings, :enabled, from: true, to: false
change_column_null :project_error_tracking_settings, :api_url, true
end
# rubocop:enable Migration/PreventStrings
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 AddSortingFieldsToUserPreference < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def up
add_column :user_preferences, :issues_sort, :string
add_column :user_preferences, :merge_requests_sort, :string
end
# rubocop:enable Migration/PreventStrings
def down
remove_column :user_preferences, :issues_sort
remove_column :user_preferences, :merge_requests_sort
end
end

View file

@ -1,11 +0,0 @@
# frozen_string_literal: true
class AddLocalCachedMarkdownVersion < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :application_settings, :local_markdown_version, :integer, default: 0, null: false
end
end

View file

@ -1,18 +0,0 @@
# frozen_string_literal: true
class AddIndexToTags < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'index_tags_on_name_trigram'
disable_ddl_transaction!
def up
add_concurrent_index :tags, :name, name: INDEX_NAME, using: :gin, opclass: { name: :gin_trgm_ops }
end
def down
remove_concurrent_index_by_name(:tags, INDEX_NAME)
end
end

View file

@ -1,17 +0,0 @@
# frozen_string_literal: true
class AddStateIdToIssuables < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
add_column :issues, :state_id, :integer, limit: 2
add_column :merge_requests, :state_id, :integer, limit: 2
end
def down
remove_column :issues, :state_id
remove_column :merge_requests, :state_id
end
end

View file

@ -1,11 +0,0 @@
# frozen_string_literal: true
class AddMergePipelinesEnabledToCiCdSettings < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :project_ci_cd_settings, :merge_pipelines_enabled, :boolean
end
end

View file

@ -1,21 +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 AddMaskedToCiVariables < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default :ci_variables, :masked, :boolean, default: false, allow_null: false # rubocop:disable Migration/AddColumnWithDefault
end
def down
remove_column :ci_variables, :masked
end
end

View file

@ -1,21 +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 AddMaskedToCiGroupVariables < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default :ci_group_variables, :masked, :boolean, default: false, allow_null: false # rubocop:disable Migration/AddColumnWithDefault
end
def down
remove_column :ci_group_variables, :masked
end
end

View file

@ -1,20 +0,0 @@
# frozen_string_literal: true
class AddAssetProxySettings < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
# rubocop:disable Migration/AddLimitToTextColumns
def change
add_column :application_settings, :asset_proxy_enabled, :boolean, default: false, null: false
add_column :application_settings, :asset_proxy_url, :string
add_column :application_settings, :asset_proxy_whitelist, :text
add_column :application_settings, :encrypted_asset_proxy_secret_key, :text
add_column :application_settings, :encrypted_asset_proxy_secret_key_iv, :string
end
# rubocop:enable Migration/AddLimitToTextColumns
# rubocop:enable Migration/PreventStrings
end

View file

@ -1,17 +0,0 @@
# frozen_string_literal: true
class AddEmailHeaderAndFooterEnabledFlagToAppearancesTable < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
DOWNTIME = false
def up
add_column_with_default(:appearances, :email_header_and_footer_enabled, :boolean, default: false) # rubocop:disable Migration/AddColumnWithDefault
end
def down
remove_column(:appearances, :email_header_and_footer_enabled)
end
end

View file

@ -1,12 +0,0 @@
# frozen_string_literal: true
class AddExtraShasToCiPipelines < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :ci_pipelines, :source_sha, :binary
add_column :ci_pipelines, :target_sha, :binary
end
end

View file

@ -1,42 +0,0 @@
# frozen_string_literal: true
class AddIndexesForMergeRequestDiffsQuery < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_SPECS = [
[
:merge_request_metrics,
:latest_closed_at,
{ where: 'latest_closed_at IS NOT NULL' }
],
[
:merge_request_metrics,
[:merge_request_id, :merged_at],
{ where: 'merged_at IS NOT NULL' }
],
[
:merge_request_diffs,
[:merge_request_id, :id],
{
name: 'index_merge_request_diffs_on_merge_request_id_and_id_partial',
where: 'NOT stored_externally OR stored_externally IS NULL'
}
]
].freeze
disable_ddl_transaction!
def up
INDEX_SPECS.each do |spec|
add_concurrent_index(*spec)
end
end
def down
INDEX_SPECS.reverse_each do |spec|
remove_concurrent_index(*spec)
end
end
end

View file

@ -1,9 +0,0 @@
# frozen_string_literal: true
class AddAutoDevOpsEnabledToNamespaces < ActiveRecord::Migration[5.0]
DOWNTIME = false
def change
add_column :namespaces, :auto_devops_enabled, :boolean # rubocop:disable Migration/AddColumnsToWideTables
end
end

View file

@ -1,24 +0,0 @@
# frozen_string_literal: true
class AddRunnerTokensIndexes < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
# It seems that `ci_runners.token_encrypted` and `projects.runners_token_encrypted`
# are non-unique
def up
add_concurrent_index :ci_runners, :token_encrypted
add_concurrent_index :projects, :runners_token_encrypted
add_concurrent_index :namespaces, :runners_token_encrypted, unique: true
end
def down
remove_concurrent_index :ci_runners, :token_encrypted
remove_concurrent_index :projects, :runners_token_encrypted
remove_concurrent_index :namespaces, :runners_token_encrypted, unique: true
end
end

View file

@ -1,19 +0,0 @@
# frozen_string_literal: true
class AddMultiLineAttributesToSuggestion < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default :suggestions, :lines_above, :integer, default: 0, allow_null: false # rubocop:disable Migration/AddColumnWithDefault
add_column_with_default :suggestions, :lines_below, :integer, default: 0, allow_null: false # rubocop:disable Migration/AddColumnWithDefault
add_column_with_default :suggestions, :outdated, :boolean, default: false, allow_null: false # rubocop:disable Migration/AddColumnWithDefault
end
def down
remove_columns :suggestions, :outdated, :lines_above, :lines_below
end
end

View file

@ -1,12 +0,0 @@
# frozen_string_literal: true
class AddExternalHostnameToIngressAndKnative < ActiveRecord::Migration[5.0]
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change
add_column :clusters_applications_ingress, :external_hostname, :string
add_column :clusters_applications_knative, :external_hostname, :string
end
# rubocop:enable Migration/PreventStrings
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 AddDetectedRepositoryLanguagesToProjects < ActiveRecord::Migration[5.0]
DOWNTIME = false
def change
add_column :projects, :detected_repository_languages, :boolean # rubocop:disable Migration/AddColumnsToWideTables
end
end

View file

@ -1,10 +0,0 @@
# frozen_string_literal: true
class AddRemoveAtToPagesDomains < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :pages_domains, :remove_at, :datetime_with_timezone
end
end

View file

@ -1,19 +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 AddRemoveAtIndexToPagesDomains < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :pages_domains, :remove_at
end
def down
remove_concurrent_index :pages_domains, :remove_at
end
end

View file

@ -1,22 +0,0 @@
# frozen_string_literal: true
class CreateMergeRequestAssigneesTable < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'index_merge_request_assignees_on_merge_request_id_and_user_id'
def up
create_table :merge_request_assignees do |t|
t.references :user, foreign_key: { on_delete: :cascade }, index: true, null: false
t.references :merge_request, foreign_key: { on_delete: :cascade }, null: false
end
add_index :merge_request_assignees, [:merge_request_id, :user_id], unique: true, name: INDEX_NAME
end
def down
drop_table :merge_request_assignees
end
end

View file

@ -1,17 +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 AddLetsEncryptNotificationEmailToApplicationSettings < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change
add_column :application_settings, :lets_encrypt_notification_email, :string
end
# rubocop:enable Migration/PreventStrings
end

View file

@ -1,17 +0,0 @@
# frozen_string_literal: true
class AddAutoSslEnabledToPagesDomain < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default :pages_domains, :auto_ssl_enabled, :boolean, default: false # rubocop:disable Migration/AddColumnWithDefault
end
def down
remove_column :pages_domains, :auto_ssl_enabled
end
end

View file

@ -1,23 +0,0 @@
# frozen_string_literal: true
# rubocop:disable Migration/UpdateLargeTable
class TruncateUserFullname < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
truncated_name = Arel.sql('SUBSTRING(name from 1 for 128)')
where_clause = Arel.sql("LENGTH(name) > 128")
update_column_in_batches(:users, :name, truncated_name) do |table, query|
query.where(where_clause)
end
end
def down
# noop
end
end

View file

@ -1,24 +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 AddFieldsToUserPreferences < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
DOWNTIME = false
def up
add_column(:user_preferences, :timezone, :string) # rubocop:disable Migration/PreventStrings
add_column(:user_preferences, :time_display_relative, :boolean)
add_column(:user_preferences, :time_format_in_24h, :boolean)
end
def down
remove_column(:user_preferences, :timezone)
remove_column(:user_preferences, :time_display_relative)
remove_column(:user_preferences, :time_format_in_24h)
end
end

View file

@ -1,17 +0,0 @@
# frozen_string_literal: true
class AddManagedToCluster < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
DOWNTIME = false
def up
add_column_with_default(:clusters, :managed, :boolean, default: true) # rubocop:disable Migration/AddColumnWithDefault
end
def down
remove_column(:clusters, :managed)
end
end

View file

@ -1,15 +0,0 @@
# frozen_string_literal: true
class ImportCommonMetricsKnative < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
::Gitlab::DatabaseImporters::CommonMetrics::Importer.new.execute
end
def down
# no-op
end
end

View file

@ -1,13 +0,0 @@
# frozen_string_literal: true
class AddNotificationEmailToNotificationSettings < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change
add_column :notification_settings, :notification_email, :string
end
# rubocop:enable Migration/PreventStrings
end

View file

@ -1,21 +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 AddLetsEncryptTermsOfServiceAcceptedToApplicationSettings < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default(:application_settings, :lets_encrypt_terms_of_service_accepted, :boolean, default: false) # rubocop:disable Migration/AddColumnWithDefault
end
def down
remove_column :application_settings, :lets_encrypt_terms_of_service_accepted
end
end

File diff suppressed because it is too large Load diff

View file

@ -1,21 +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 UpdateDesignsIndex < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
remove_concurrent_index :design_management_designs, :issue_id, unique: true
end
def down
add_concurrent_index :design_management_designs, :issue_id, unique: true
end
end

View file

@ -1,18 +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 PrometheusKnative05Fix < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
::Gitlab::DatabaseImporters::CommonMetrics::Importer.new.execute
end
def down
# no-op
end
end

View file

@ -1,26 +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 AddNameToGeoNodes < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def up
add_column :geo_nodes, :name, :string # rubocop:disable Migration/PreventStrings
# url is also unique, and its type and size is identical to the name column,
# so this is safe.
execute "UPDATE geo_nodes SET name = url;"
# url is also `null: false`, so this is safe.
change_column :geo_nodes, :name, :string, null: false
end
def down
remove_column :geo_nodes, :name
end
end

View file

@ -1,21 +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 AddNameIndexToGeoNodes < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :geo_nodes, :name, unique: true
end
def down
remove_concurrent_index :geo_nodes, :name
end
end

View file

@ -1,25 +0,0 @@
# frozen_string_literal: true
class AddMergeRequestBlocks < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
create_table :merge_request_blocks, id: :bigserial do |t|
t.references :blocking_merge_request,
index: false, null: false,
foreign_key: { to_table: :merge_requests, on_delete: :cascade }
t.references :blocked_merge_request,
index: true, null: false,
foreign_key: { to_table: :merge_requests, on_delete: :cascade }
t.index [:blocking_merge_request_id, :blocked_merge_request_id],
unique: true,
name: 'index_mr_blocks_on_blocking_and_blocked_mr_ids'
t.timestamps_with_timezone
end
end
end

View file

@ -1,21 +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 RemoveUrlIndexFromGeoNodes < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
remove_concurrent_index :geo_nodes, :url
end
def down
add_concurrent_index :geo_nodes, :url, unique: true
end
end

View file

@ -1,17 +0,0 @@
# frozen_string_literal: true
class AddCommentToVulnerabilityFeedback < ActiveRecord::Migration[5.1]
DOWNTIME = false
def up
add_column :vulnerability_feedback, :comment_author_id, :integer
add_column :vulnerability_feedback, :comment, :text # rubocop:disable Migration/AddLimitToTextColumns
add_column :vulnerability_feedback, :comment_timestamp, :datetime_with_timezone
end
def down
remove_column :vulnerability_feedback, :comment_author_id
remove_column :vulnerability_feedback, :comment
remove_column :vulnerability_feedback, :comment_timestamp
end
end

View file

@ -1,17 +0,0 @@
# frozen_string_literal: true
class AddVariableTypeToCiVariables < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
DOWNTIME = false
ENV_VAR_VARIABLE_TYPE = 1
def up
add_column_with_default(:ci_variables, :variable_type, :smallint, default: ENV_VAR_VARIABLE_TYPE) # rubocop:disable Migration/AddColumnWithDefault
end
def down
remove_column(:ci_variables, :variable_type)
end
end

View file

@ -1,11 +0,0 @@
# frozen_string_literal: true
class AddPackagesSizeToProjectStatistics < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :project_statistics, :packages_size, :bigint
end
end

View file

@ -1,25 +0,0 @@
# frozen_string_literal: true
# rubocop: disable Migration/AddConcurrentForeignKey
class UpdateInsightsForeignKeys < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
remove_foreign_key_if_exists(:insights, column: :project_id)
add_foreign_key(:insights, :projects, column: :project_id, on_delete: :cascade)
remove_foreign_key_if_exists(:insights, column: :namespace_id)
add_foreign_key(:insights, :namespaces, column: :namespace_id, on_delete: :cascade)
end
def down
remove_foreign_key_if_exists(:insights, column: :namespace_id)
add_foreign_key(:insights, :namespaces, column: :namespace_id)
remove_foreign_key_if_exists(:insights, column: :project_id)
add_foreign_key(:insights, :projects, column: :project_id)
end
end

View file

@ -1,21 +0,0 @@
# frozen_string_literal: true
class AddMergeTrainEnabledToCiCdSettings < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
# rubocop:disable Migration/AddColumnWithDefault
# rubocop:disable Migration/UpdateLargeTable
def up
add_column_with_default :project_ci_cd_settings, :merge_trains_enabled, :boolean, default: false, allow_null: false
end
# rubocop:enable Migration/AddColumnWithDefault
# rubocop:enable Migration/UpdateLargeTable
def down
remove_column :project_ci_cd_settings, :merge_trains_enabled
end
end

View file

@ -1,17 +0,0 @@
# frozen_string_literal: true
class AddVariableTypeToCiGroupVariables < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
DOWNTIME = false
ENV_VAR_VARIABLE_TYPE = 1
def up
add_column_with_default(:ci_group_variables, :variable_type, :smallint, default: ENV_VAR_VARIABLE_TYPE) # rubocop:disable Migration/AddColumnWithDefault
end
def down
remove_column(:ci_group_variables, :variable_type)
end
end

View file

@ -1,21 +0,0 @@
# frozen_string_literal: true
class AddVariableTypeToCiPipelineVariables < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
DOWNTIME = false
ENV_VAR_VARIABLE_TYPE = 1
# rubocop:disable Migration/AddColumnWithDefault
# rubocop:disable Migration/UpdateLargeTable
def up
add_column_with_default(:ci_pipeline_variables, :variable_type, :smallint, default: ENV_VAR_VARIABLE_TYPE)
end
# rubocop:enable Migration/AddColumnWithDefault
# rubocop:enable Migration/UpdateLargeTable
def down
remove_column(:ci_pipeline_variables, :variable_type)
end
end

View file

@ -1,17 +0,0 @@
# frozen_string_literal: true
class AddVariableTypeToCiPipelineScheduleVariables < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
DOWNTIME = false
ENV_VAR_VARIABLE_TYPE = 1
def up
add_column_with_default(:ci_pipeline_schedule_variables, :variable_type, :smallint, default: ENV_VAR_VARIABLE_TYPE) # rubocop:disable Migration/AddColumnWithDefault
end
def down
remove_column(:ci_pipeline_schedule_variables, :variable_type)
end
end

View file

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

View file

@ -1,18 +0,0 @@
# frozen_string_literal: true
class CreateMergeRequestTrainsTable < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
create_table :merge_trains, id: :bigserial do |t|
t.references :merge_request, foreign_key: { on_delete: :cascade }, type: :integer, index: false, null: false
t.references :user, foreign_key: { on_delete: :cascade }, type: :integer, null: false
t.references :pipeline, foreign_key: { to_table: :ci_pipelines, on_delete: :nullify }, type: :integer
t.timestamps_with_timezone null: false
t.index [:merge_request_id], unique: true
end
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 AddBridgedPipelineIdToBridges < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def change
add_column :ci_builds, :upstream_pipeline_id, :integer # rubocop:disable Migration/AddColumnsToWideTables
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 AddBridgedPipelineIdForeignKey < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :ci_builds, :upstream_pipeline_id, where: 'upstream_pipeline_id IS NOT NULL'
add_concurrent_foreign_key :ci_builds, :ci_pipelines, column: :upstream_pipeline_id
end
def down
remove_foreign_key :ci_builds, column: :upstream_pipeline_id
remove_concurrent_index :ci_builds, :upstream_pipeline_id
end
end

View file

@ -1,14 +0,0 @@
# frozen_string_literal: true
class CreateProjectMetricsSettings < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
create_table :project_metrics_settings, id: :int, primary_key: :project_id, default: nil do |t|
t.string :external_dashboard_url, null: false # rubocop:disable Migration/PreventStrings
t.foreign_key :projects, column: :project_id, on_delete: :cascade
end
end
end

View file

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

View file

@ -1,21 +0,0 @@
# frozen_string_literal: true
class AddDeploymentEventsToServices < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
# rubocop:disable Migration/AddColumnWithDefault
# rubocop:disable Migration/UpdateLargeTable
def up
add_column_with_default(:services, :deployment_events, :boolean, default: false, allow_null: false)
end
# rubocop:enable Migration/AddColumnWithDefault
# rubocop:enable Migration/UpdateLargeTable
def down
remove_column(:services, :deployment_events)
end
end

View file

@ -1,32 +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 CreatePagesDomainAcmeOrders < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
# rubocop:disable Migration/AddLimitToTextColumns
def change
create_table :pages_domain_acme_orders do |t|
t.references :pages_domain, null: false, index: true, foreign_key: { on_delete: :cascade }, type: :integer
t.datetime_with_timezone :expires_at, null: false
t.timestamps_with_timezone null: false
t.string :url, null: false
t.string :challenge_token, null: false, index: true
t.text :challenge_file_content, null: false
t.text :encrypted_private_key, null: false
t.text :encrypted_private_key_iv, null: false
end
end
# rubocop:enable Migration/AddLimitToTextColumns
# rubocop:enable Migration/PreventStrings
end

View file

@ -1,25 +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 CreateIssueTrackerData < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change
create_table :issue_tracker_data do |t|
t.references :service, foreign_key: { on_delete: :cascade }, type: :integer, index: true, null: false
t.timestamps_with_timezone
t.string :encrypted_project_url
t.string :encrypted_project_url_iv
t.string :encrypted_issues_url
t.string :encrypted_issues_url_iv
t.string :encrypted_new_issue_url
t.string :encrypted_new_issue_url_iv
end
end
# rubocop:enable Migration/PreventStrings
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 CreateJiraTrackerData < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change
create_table :jira_tracker_data do |t|
t.references :service, foreign_key: { on_delete: :cascade }, type: :integer, index: true, null: false
t.timestamps_with_timezone
t.string :encrypted_url
t.string :encrypted_url_iv
t.string :encrypted_api_url
t.string :encrypted_api_url_iv
t.string :encrypted_username
t.string :encrypted_username_iv
t.string :encrypted_password
t.string :encrypted_password_iv
t.string :jira_issue_transition_id
end
end
# rubocop:enable Migration/PreventStrings
end

View file

@ -1,34 +0,0 @@
# frozen_string_literal: true
# This migration adds temporary indexes to state_id column of issues
# and merge_requests tables. It will be used only to peform the scheduling
# for populating state_id in a post migrate and will be removed after it.
# Check: ScheduleSyncIssuablesStateIdWhereNil.
class AddTemporaryIndexesToStateId < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
%w(issues merge_requests).each do |table|
add_concurrent_index(
table,
'id',
name: index_name_for(table),
where: "state_id IS NULL"
)
end
end
def down
remove_concurrent_index_by_name(:issues, index_name_for("issues"))
remove_concurrent_index_by_name(:merge_requests, index_name_for("merge_requests"))
end
def index_name_for(table)
"idx_on_#{table}_where_state_id_is_null"
end
end

View file

@ -1,19 +0,0 @@
# frozen_string_literal: true
class EnableCreateIncidentIssuesByDefault < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
change_default_for :create_issue, from: false, to: true
change_default_for :send_email, from: true, to: false
end
private
def change_default_for(column, from:, to:)
change_column_default :project_incident_management_settings,
column, from: from, to: to
end
end

View file

@ -1,20 +0,0 @@
# frozen_string_literal: true
class CreateIpRestriction < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
create_table :ip_restrictions do |t|
t.references :group, references: :namespace,
column: :group_id,
type: :integer,
null: false,
index: true
t.string :range, null: false # rubocop:disable Migration/PreventStrings
end
add_foreign_key(:ip_restrictions, :namespaces, column: :group_id, on_delete: :cascade) # rubocop: disable Migration/AddConcurrentForeignKey
end
end

View file

@ -1,10 +0,0 @@
# frozen_string_literal: true
class AddApplicationSettingsElasticsearchShards < ActiveRecord::Migration[5.1]
DOWNTIME = false
def change
add_column :application_settings, :elasticsearch_shards, :integer, null: false, default: 5
add_column :application_settings, :elasticsearch_replicas, :integer, null: false, default: 1
end
end

View file

@ -1,19 +0,0 @@
# frozen_string_literal: true
# This migration make queued_at field indexed to speed up builds filtering by job_age
class AddBuildQueuedAtIndex < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :ci_builds, :queued_at
end
def down
remove_concurrent_index :ci_builds, :queued_at
end
end

View file

@ -1,18 +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 AddLetsEncryptPrivateKeyToApplicationSettings < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
# rubocop:disable Migration/AddLimitToTextColumns
def change
add_column :application_settings, :encrypted_lets_encrypt_private_key, :text
add_column :application_settings, :encrypted_lets_encrypt_private_key_iv, :text
end
# rubocop:enable Migration/AddLimitToTextColumns
end

View file

@ -1,24 +0,0 @@
# frozen_string_literal: true
class ChangePackagesSizeDefaultsInProjectStatistics < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
change_column_default :project_statistics, :packages_size, 0
update_column_in_batches(:project_statistics, :packages_size, 0) do |table, query|
query.where(table[:packages_size].eq(nil))
end
change_column_null :project_statistics, :packages_size, false
end
def down
change_column_null :project_statistics, :packages_size, true
change_column_default :project_statistics, :packages_size, nil
end
end

View file

@ -1,21 +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 AddRuleTypeToApprovalMergeRequestApprovalRules < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default(:approval_merge_request_rules, :rule_type, :integer, limit: 2, default: 1) # rubocop:disable Migration/AddColumnWithDefault
end
def down
remove_column(:approval_merge_request_rules, :rule_type)
end
end

View file

@ -1,13 +0,0 @@
# frozen_string_literal: true
class AddReportTypeToApprovalMergeRequestRules < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
change_table :approval_merge_request_rules do |t|
t.integer :report_type, limit: 2
end
end
end

View file

@ -1,38 +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 LimitMilestoneDateYearsTo4Digits < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
# When a migration requires downtime you **must** uncomment the following
# constant and define a short and easy to understand explanation as to why the
# migration requires downtime.
# DOWNTIME_REASON = ''
# When using the methods "add_concurrent_index", "remove_concurrent_index" or
# "add_column_with_default" you must disable the use of transactions
# as these methods can not run in an existing transaction.
# When using "add_concurrent_index" or "remove_concurrent_index" methods make sure
# that either of them is the _only_ method called in the migration,
# any other changes should go in a separate migration.
# This ensures that upon failure _only_ the index creation or removing fails
# and can be retried or reverted easily.
#
# To disable transactions uncomment the following line and remove these
# comments:
# disable_ddl_transaction!
def change
Milestone.where("start_date > '9999-12-31'").update_all(
"start_date = '9999-12-31'"
)
Milestone.where("due_date > '9999-12-31'").update_all(
"due_date = '9999-12-31'"
)
end
end

View file

@ -1,18 +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 GenerateLetsEncryptPrivateKey < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
# we now generate this key on the fly, but since this migration was merged to master, we don't remove it
def up
end
def down
end
end

View file

@ -1,16 +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 AddSslValidPeriodToPagesDomain < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def change
add_column :pages_domains, :certificate_valid_not_before, :datetime_with_timezone
add_column :pages_domains, :certificate_valid_not_after, :datetime_with_timezone
end
end

View file

@ -1,17 +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 AddRequiredTemplateNameToApplicationSettings < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change
add_column :application_settings, :required_instance_ci_template, :string, null: true
end
# rubocop:enable Migration/PreventStrings
end

View file

@ -1,9 +0,0 @@
# frozen_string_literal: true
class AddWikiSizeToStatistics < ActiveRecord::Migration[5.0]
DOWNTIME = false
def change
add_column :project_statistics, :wiki_size, :bigint
end
end

View file

@ -1,55 +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 AddIndexForCodeOwnerRuleTypeOnApprovalMergeRequestRules < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
INDEX_CODE_OWNERS_RULES_UNIQUENESS_NAME = 'index_approval_rule_name_for_code_owners_rule_type'
INDEX_CODE_OWNERS_RULES_QUERY_NAME = 'index_approval_rules_code_owners_rule_type'
class ApprovalMergeRequestRule < ActiveRecord::Base
include EachBatch
enum rule_types: {
regular: 1,
code_owner: 2
}
end
def up
# Ensure only 1 code_owner rule per merge_request
add_concurrent_index(
:approval_merge_request_rules,
[:merge_request_id, :rule_type, :name],
unique: true,
where: "rule_type = #{ApprovalMergeRequestRule.rule_types[:code_owner]}",
name: INDEX_CODE_OWNERS_RULES_UNIQUENESS_NAME
)
# Support lookups for all code_owner rules per merge_request
add_concurrent_index(
:approval_merge_request_rules,
[:merge_request_id, :rule_type],
where: "rule_type = #{ApprovalMergeRequestRule.rule_types[:code_owner]}",
name: INDEX_CODE_OWNERS_RULES_QUERY_NAME
)
end
def down
remove_concurrent_index_by_name(
:approval_merge_request_rules,
INDEX_CODE_OWNERS_RULES_UNIQUENESS_NAME
)
remove_concurrent_index_by_name(
:approval_merge_request_rules,
INDEX_CODE_OWNERS_RULES_QUERY_NAME
)
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 AddDnsRebindingProtectionEnabledToApplicationSettings < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default(:application_settings, :dns_rebinding_protection_enabled, # rubocop:disable Migration/AddColumnWithDefault
:boolean,
default: true,
allow_null: false)
end
def down
remove_column(:application_settings, :dns_rebinding_protection_enabled)
end
end

View file

@ -1,11 +0,0 @@
# frozen_string_literal: true
class AddDefaultGitDepthToCiCdSettings < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :project_ci_cd_settings, :default_git_depth, :integer
end
end

View file

@ -1,21 +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 AddIndexToMergeRequestsStateAndMergeStatus < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :merge_requests, [:state, :merge_status],
where: "state = 'opened' AND merge_status = 'can_be_merged'"
end
def down
remove_concurrent_index :merge_requests, [:state, :merge_status]
end
end

View file

@ -1,22 +0,0 @@
# frozen_string_literal: true
class CreateNamespaceRootStorageStatistics < ActiveRecord::Migration[5.1]
DOWNTIME = false
def change
create_table :namespace_root_storage_statistics, id: false, primary_key: :namespace_id do |t|
t.integer :namespace_id, null: false, primary_key: true
t.datetime_with_timezone :updated_at, null: false
t.bigint :repository_size, null: false, default: 0
t.bigint :lfs_objects_size, null: false, default: 0
t.bigint :wiki_size, null: false, default: 0
t.bigint :build_artifacts_size, null: false, default: 0
t.bigint :storage_size, null: false, default: 0
t.bigint :packages_size, null: false, default: 0
t.index :namespace_id, unique: true
t.foreign_key :namespaces, column: :namespace_id, on_delete: :cascade
end
end
end

View file

@ -1,11 +0,0 @@
# frozen_string_literal: true
class AddRepositoryTypeToLfsObjectsProject < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :lfs_objects_projects, :repository_type, :integer, limit: 2, null: true
end
end

View file

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

View file

@ -1,20 +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 AddLdapMembershipLock < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default(:application_settings, :lock_memberships_to_ldap, :boolean, default: false) # rubocop:disable Migration/AddColumnWithDefault
end
def down
remove_column(:application_settings, :lock_memberships_to_ldap)
end
end

View file

@ -1,19 +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 FixPoolRepositorySourceProjectId < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def up
execute "UPDATE pool_repositories SET source_project_id = (SELECT MIN(id) FROM projects WHERE pool_repository_id = pool_repositories.id) WHERE pool_repositories.source_project_id IS NULL"
end
def down
# nothing to do her
end
end

View file

@ -1,22 +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 AddDefaultProjectDeletionProtectionToApplicationSettings < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
# rubocop:disable Migration/AddColumnWithDefault
add_column_with_default :application_settings, :default_project_deletion_protection, :boolean, default: false, allow_null: false
# rubocop:enable Migration/AddColumnWithDefault
end
def down
remove_column :application_settings, :default_project_deletion_protection
end
end

View file

@ -1,14 +0,0 @@
# frozen_string_literal: true
class CreateNamespaceAggregationSchedules < ActiveRecord::Migration[5.1]
DOWNTIME = false
def change
create_table :namespace_aggregation_schedules, id: false, primary_key: :namespace_id do |t|
t.integer :namespace_id, null: false, primary_key: true
t.index :namespace_id, unique: true
t.foreign_key :namespaces, column: :namespace_id, on_delete: :cascade
end
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 AddLastCiMinutesNotificationAtToNamespaces < ActiveRecord::Migration[5.1]
DOWNTIME = false
def change
add_column :namespaces, :last_ci_minutes_notification_at, :datetime_with_timezone # rubocop:disable Migration/AddColumnsToWideTables
end
end

View file

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

View file

@ -1,11 +0,0 @@
# frozen_string_literal: true
class ChangeOperationsFeatureFlagsClientsTokenNotNull < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
change_column_null :operations_feature_flags_clients, :token, true
end
end

View file

@ -1,13 +0,0 @@
# frozen_string_literal: true
class AddTokenEncryptedToOperationsFeatureFlagsClients < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
# rubocop:disable Migration/PreventStrings
def change
add_column :operations_feature_flags_clients, :token_encrypted, :string
end
# rubocop:enable Migration/PreventStrings
end

View file

@ -1,18 +0,0 @@
# frozen_string_literal: true
class AddIndexToOperationsFeatureFlagsClientsTokenEncrypted < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :operations_feature_flags_clients, [:project_id, :token_encrypted],
unique: true, name: "index_feature_flags_clients_on_project_id_and_token_encrypted"
end
def down
remove_concurrent_index_by_name :operations_feature_flags_clients, "index_feature_flags_clients_on_project_id_and_token_encrypted"
end
end

View file

@ -1,11 +0,0 @@
# frozen_string_literal: true
class AddNameToBadges < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :badges, :name, :string, null: true, limit: 255 # rubocop:disable Migration/PreventStrings
end
end

View file

@ -1,21 +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 AddSourceToPagesDomains < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default(:pages_domains, :certificate_source, :smallint, default: 0) # rubocop:disable Migration/AddColumnWithDefault
end
def down
remove_column(:pages_domains, :certificate_source)
end
end

View file

@ -1,25 +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 AddPagesDomainsSslRenewIndex < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
INDEX_NAME = 'index_pages_domains_need_auto_ssl_renewal'
disable_ddl_transaction!
def up
add_concurrent_index(:pages_domains, [:certificate_source, :certificate_valid_not_after],
where: "auto_ssl_enabled = #{::Gitlab::Database.true_value}", name: INDEX_NAME)
end
def down
remove_concurrent_index(:pages_domains, [:certificate_source, :certificate_valid_not_after],
where: "auto_ssl_enabled = #{::Gitlab::Database.true_value}", name: INDEX_NAME)
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 AddIndexToUsersPublicEmails < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :users, [:public_email],
where: "public_email != ''"
end
def down
remove_concurrent_index :users, [:public_email],
where: "public_email != ''"
end
end

View file

@ -1,12 +0,0 @@
# frozen_string_literal: true
class AddWikiColumnsToIndexStatus < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :index_statuses, :last_wiki_commit, :binary
add_column :index_statuses, :wiki_indexed_at, :datetime_with_timezone
end
end

View file

@ -1,21 +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 AddIndexToMembersInviteEmail < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :members, [:invite_email]
end
def down
remove_concurrent_index :members, [:invite_email]
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 AddTimeTrackingLimitToHoursToApplicationSettings < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
# rubocop:disable Migration/AddColumnWithDefault
add_column_with_default :application_settings, :time_tracking_limit_to_hours, :boolean, default: false, allow_null: false
# rubocop:enable Migration/AddColumnWithDefault
end
def down
remove_column :application_settings, :time_tracking_limit_to_hours
end
end

View file

@ -1,17 +0,0 @@
# frozen_string_literal: true
class AddGeoContainerRepositoryUpdatedEventsTable < ActiveRecord::Migration[5.1]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
create_table :geo_container_repository_updated_events, force: :cascade do |t|
t.integer :container_repository_id, null: false
t.index :container_repository_id, name: :idx_geo_con_rep_updated_events_on_container_repository_id, using: :btree
end
add_column :geo_event_log, :container_repository_updated_event_id, :bigint
end
end

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