Skip to content
Snippets Groups Projects
Verified Commit 8af4455f authored by Kev Kloss's avatar Kev Kloss :m: Committed by GitLab
Browse files

Update tff mapping tests

The used migration was removed, so we need to use an existing one here.
parent f4923fdb
No related branches found
No related tags found
2 merge requests!170053Security patch upgrade alert: Only expose to admins 17-4,!167772Squash database migrations up to 16-4-stable-ee
Showing
with 0 additions and 394 deletions
# frozen_string_literal: true
class AddPathPrefixAndBuildRefToPagesDeployments < Gitlab::Database::Migration[2.1]
enable_lock_retries!
# rubocop:disable Migration/AddLimitToTextColumns
# limit is added in 20230809165213_add_index_to_path_prefix_and_ref_to_pages_deployments
def change
add_column :pages_deployments, :path_prefix, :text
add_column :pages_deployments, :build_ref, :text
end
# rubocop:enable Migration/AddLimitToTextColumns
end
# frozen_string_literal: true
class AddIndexToPathPrefixAndBuildRefToPagesDeployments < Gitlab::Database::Migration[2.1]
disable_ddl_transaction!
TABLE_NAME = :pages_deployments
INDEX_NAME = 'index_pages_deployments_unique_path_prefix_by_project'
def up
add_text_limit TABLE_NAME, :path_prefix, 128
add_text_limit TABLE_NAME, :build_ref, 512
add_concurrent_index TABLE_NAME,
[:project_id, :path_prefix],
name: INDEX_NAME,
unique: true
end
def down
remove_text_limit TABLE_NAME, :path_prefix
remove_text_limit TABLE_NAME, :build_ref
remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME
end
end
# frozen_string_literal: true
class AddFileSizeLimitToPlanLimits < Gitlab::Database::Migration[2.1]
def change
add_column :plan_limits, :file_size_limit_mb, :float, default: 100, null: false
end
end
# frozen_string_literal: true
class AddHasRemediationsToVulnerabilityReads < Gitlab::Database::Migration[2.1]
enable_lock_retries!
def up
add_column :vulnerability_reads, :has_remediations, :boolean, default: false, null: false
end
def down
remove_column :vulnerability_reads, :has_remediations
end
end
# frozen_string_literal: true
class AddPipelineIdAndExportTypeToDependencyListExports < Gitlab::Database::Migration[2.1]
def change
add_column :dependency_list_exports, :pipeline_id, :bigint
add_column :dependency_list_exports, :export_type, :integer, limit: 2, default: 0, null: false
end
end
# frozen_string_literal: true
class AddIndexPipelineIdToDependencyListExports < Gitlab::Database::Migration[2.1]
disable_ddl_transaction!
INDEX_NAME = 'index_dependency_list_exports_on_pipeline_id'
def up
add_concurrent_index :dependency_list_exports, :pipeline_id, name: INDEX_NAME
end
def down
remove_concurrent_index_by_name :dependency_list_exports, INDEX_NAME
end
end
# frozen_string_literal: true
class UpdatePackageMetadataSyncSetting < Gitlab::Database::Migration[2.1]
restrict_gitlab_migration gitlab_schema: :gitlab_main
class ApplicationSetting < MigrationRecord
end
FULLY_ENABLED_SYNC = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].freeze
def up
application_setting = ApplicationSetting.last
return unless application_setting
# Check if the setting still has a default value and it wasn't updated manually by the admin
return unless application_setting.package_metadata_purl_types == []
# Update setting to enable all package types to sync
application_setting.update(package_metadata_purl_types: FULLY_ENABLED_SYNC)
end
def down
# no op
end
end
# frozen_string_literal: true
class UpdateDefaultValuePm < Gitlab::Database::Migration[2.1]
disable_ddl_transaction!
FULLY_ENABLED_SYNC = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].freeze
def change
change_column_default :application_settings, :package_metadata_purl_types, from: [], to: FULLY_ENABLED_SYNC
end
end
# frozen_string_literal: true
class ChangePersonalAccessTokensRemoveNotNullExpiresAt < Gitlab::Database::Migration[2.2]
milestone '16.6'
disable_ddl_transaction!
CONSTRAINT_NAME = 'check_b8d60815eb'
def up
remove_not_null_constraint :personal_access_tokens, :expires_at
end
def down
add_not_null_constraint :personal_access_tokens, :expires_at, validate: false, constraint_name: CONSTRAINT_NAME
end
end
# frozen_string_literal: true
class QueueBackfillDismissalReasonInVulnerabilityReads < Gitlab::Database::Migration[2.1]
MIGRATION = "BackfillDismissalReasonInVulnerabilityReads"
DELAY_INTERVAL = 2.minutes
BATCH_SIZE = 5000
SUB_BATCH_SIZE = 500
restrict_gitlab_migration gitlab_schema: :gitlab_main
def up
Gitlab::Database::QueryAnalyzers::RestrictAllowedSchemas.with_suppressed do
queue_batched_background_migration(
MIGRATION,
:vulnerability_reads,
:id,
job_interval: DELAY_INTERVAL,
batch_size: BATCH_SIZE,
sub_batch_size: SUB_BATCH_SIZE
)
end
end
def down
Gitlab::Database::QueryAnalyzers::RestrictAllowedSchemas.with_suppressed do
delete_batched_background_migration(MIGRATION, :vulnerability_reads, :id, [])
end
end
end
# frozen_string_literal: true
class EnsureBackfillForCiPipelineVariablesPipelineIdIsFinished < Gitlab::Database::Migration[2.1]
include Gitlab::Database::MigrationHelpers::ConvertToBigint
restrict_gitlab_migration gitlab_schema: :gitlab_ci
disable_ddl_transaction!
TABLE_NAME = :ci_pipeline_variables
def up
# no-op
end
def down
# no-op
end
end
# frozen_string_literal: true
class EnsureAgainBackfillForCiPipelineVariablesPipelineIdIsFinished < Gitlab::Database::Migration[2.1]
include Gitlab::Database::MigrationHelpers::ConvertToBigint
restrict_gitlab_migration gitlab_schema: :gitlab_ci
disable_ddl_transaction!
TABLE_NAME = :ci_pipeline_variables
def up
ensure_batched_background_migration_is_finished(
job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
table_name: TABLE_NAME,
column_name: 'id',
job_arguments: [['pipeline_id'], ['pipeline_id_convert_to_bigint']]
)
end
def down
# no-op
end
end
# frozen_string_literal: true
class CreateAsyncIndexForCiPiplineVariablesPipelineId < Gitlab::Database::Migration[2.1]
TABLE_NAME = :ci_pipeline_variables
INDEX_NAME = "index_ci_pipeline_variables_on_pipeline_id_bigint_and_key"
def up
prepare_async_index TABLE_NAME, [:pipeline_id_convert_to_bigint, :key], unique: true, name: INDEX_NAME
end
def down
unprepare_async_index TABLE_NAME, [:pipeline_id_convert_to_bigint, :key], unique: true, name: INDEX_NAME
end
end
# frozen_string_literal: true
class EnsureTodosBigintBackfillCompletedForSelfManaged < Gitlab::Database::Migration[2.1]
include Gitlab::Database::MigrationHelpers::ConvertToBigint
restrict_gitlab_migration gitlab_schema: :gitlab_main
disable_ddl_transaction!
def up
return if should_skip?
ensure_batched_background_migration_is_finished(
job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
table_name: 'todos',
column_name: 'id',
job_arguments: [['note_id'], ['note_id_convert_to_bigint']]
)
end
def down
# no-op
end
private
def should_skip?
com_or_dev_or_test_but_not_jh?
end
end
# frozen_string_literal: true
class SwapTodosNoteIdToBigintForSelfManaged < Gitlab::Database::Migration[2.1]
include Gitlab::Database::MigrationHelpers::ConvertToBigint
disable_ddl_transaction!
TABLE_NAME = 'todos'
def up
return if should_skip?
return if temp_column_removed?(TABLE_NAME, :note_id)
return if columns_swapped?(TABLE_NAME, :note_id)
swap
end
def down
return if should_skip?
return if temp_column_removed?(TABLE_NAME, :note_id)
return unless columns_swapped?(TABLE_NAME, :note_id)
swap
end
def swap
# This will replace the existing index_todos_on_note_id
add_concurrent_index TABLE_NAME, :note_id_convert_to_bigint,
name: 'index_todos_on_note_id_convert_to_bigint'
# This will replace the existing fk_91d1f47b13
add_concurrent_foreign_key TABLE_NAME, :notes, column: :note_id_convert_to_bigint,
name: 'fk_todos_note_id_convert_to_bigint',
on_delete: :cascade
with_lock_retries(raise_on_exhaustion: true) do
execute "LOCK TABLE notes, #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE"
execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN note_id TO note_id_tmp"
execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN note_id_convert_to_bigint TO note_id"
execute "ALTER TABLE #{TABLE_NAME} RENAME COLUMN note_id_tmp TO note_id_convert_to_bigint"
function_name = Gitlab::Database::UnidirectionalCopyTrigger
.on_table(TABLE_NAME, connection: connection)
.name(:note_id, :note_id_convert_to_bigint)
execute "ALTER FUNCTION #{quote_table_name(function_name)} RESET ALL"
execute 'DROP INDEX IF EXISTS index_todos_on_note_id'
rename_index TABLE_NAME, 'index_todos_on_note_id_convert_to_bigint',
'index_todos_on_note_id'
execute "ALTER TABLE #{TABLE_NAME} DROP CONSTRAINT IF EXISTS fk_91d1f47b13"
rename_constraint(TABLE_NAME, 'fk_todos_note_id_convert_to_bigint', 'fk_91d1f47b13')
end
end
private
def should_skip?
com_or_dev_or_test_but_not_jh?
end
end
# frozen_string_literal: true
class BackfillCiPipelineChatDataPipelineIdBigintConversion < Gitlab::Database::Migration[2.1]
restrict_gitlab_migration gitlab_schema: :gitlab_ci
TABLE = :ci_pipeline_chat_data
COLUMNS = %i[pipeline_id]
SUB_BATCH_SIZE = 500
def up
backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS, sub_batch_size: SUB_BATCH_SIZE)
end
def down
revert_backfill_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
end
# frozen_string_literal: true
class ScheduleRemoveTempIndexVulnerabilityOccurrences < Gitlab::Database::Migration[2.1]
INDEX_NAME = 'tmp_idx_vulnerability_occurrences_on_id_where_report_type_7_99'
# TODO: Index to be destroyed synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/417880
def up
prepare_async_index_removal :vulnerability_occurrences, :id, where: 'report_type IN (7, 99)', name: INDEX_NAME
end
def down
unprepare_async_index :vulnerability_occurrences, :id, where: 'report_type IN (7, 99)', name: INDEX_NAME
end
end
# frozen_string_literal: true
class DropIndexDeploymentsOnProjectIdAndStatus < Gitlab::Database::Migration[2.1]
INDEX_NAME = 'index_deployments_on_project_id_and_status'
disable_ddl_transaction!
def up
remove_concurrent_index_by_name :deployments, name: INDEX_NAME
end
def down
# This is based on the following `CREATE INDEX` command in db/init_structure.sql:
# CREATE INDEX index_deployments_on_project_id_and_status ON deployments
# USING btree (project_id, status)
add_concurrent_index :deployments, %i[project_id status], name: INDEX_NAME
end
end
# frozen_string_literal: true
class DropIndexDeploymentsOnProjectIdSha < Gitlab::Database::Migration[2.1]
INDEX_NAME = 'index_deployments_on_project_id_sha'
disable_ddl_transaction!
def up
remove_concurrent_index_by_name :deployments, name: INDEX_NAME
end
def down
# This is based on the following `CREATE INDEX` command in db/init_structure.sql:
# CREATE INDEX index_deployments_on_project_id_sha ON deployments
# USING btree (project_id, sha);
add_concurrent_index :deployments, %i[project_id sha], name: INDEX_NAME
end
end
# frozen_string_literal: true
class DropIndexDeploymentsOnEnvironmentIdAndIidAndProjectId < Gitlab::Database::Migration[2.1]
INDEX_NAME = 'index_deployments_on_environment_id_and_iid_and_project_id'
disable_ddl_transaction!
def up
remove_concurrent_index_by_name :deployments, name: INDEX_NAME
end
def down
# This is based on the following `CREATE INDEX` command in db/init_structure.sql:
# CREATE INDEX index_deployments_on_environment_id_and_iid_and_project_id ON deployments
# USING btree (environment_id, iid, project_id);
add_concurrent_index :deployments, %i[environment_id iid project_id], name: INDEX_NAME
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment