diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-30 12:09:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-30 12:09:22 +0300 |
commit | ef144889c1bb80372e25f38fc89c7832ce84417a (patch) | |
tree | 54fa644c7be78fa1a562ca5f97b7f295647e1ce1 /db | |
parent | 286bddcf3c62ca6fc499e1d5b6e678c0866fecc4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
14 files changed, 217 insertions, 85 deletions
diff --git a/db/fixtures/development/12_snippets.rb b/db/fixtures/development/12_snippets.rb index 24500aa3e7d..4f885f99846 100644 --- a/db/fixtures/development/12_snippets.rb +++ b/db/fixtures/development/12_snippets.rb @@ -9,7 +9,7 @@ class Gitlab::Seeder::SnippetRepository end def import - if File.exists?(BUNDLE_PATH) + if File.exist?(BUNDLE_PATH) @snippet.repository.create_from_bundle(BUNDLE_PATH) else @snippet.repository.import_repository(SNIPPET_REPO_URL) @@ -18,7 +18,7 @@ class Gitlab::Seeder::SnippetRepository end def self.cleanup - File.delete(BUNDLE_PATH) if File.exists?(BUNDLE_PATH) + File.delete(BUNDLE_PATH) if File.exist?(BUNDLE_PATH) rescue => e warn "\nError cleaning up snippet bundle: #{e}" end diff --git a/db/migrate/20230516183736_add_container_registry_data_repair_worker_max_concurrency_to_application_settings.rb b/db/migrate/20230516183736_add_container_registry_data_repair_worker_max_concurrency_to_application_settings.rb new file mode 100644 index 00000000000..4f5708d0355 --- /dev/null +++ b/db/migrate/20230516183736_add_container_registry_data_repair_worker_max_concurrency_to_application_settings.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class AddContainerRegistryDataRepairWorkerMaxConcurrencyToApplicationSettings < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + CONSTRAINT_NAME = 'app_settings_registry_repair_worker_max_concurrency_positive' + + def up + unless column_exists?(:application_settings, :container_registry_data_repair_detail_worker_max_concurrency) + add_column :application_settings, :container_registry_data_repair_detail_worker_max_concurrency, :integer, + default: 2, null: false + end + + add_check_constraint :application_settings, + 'container_registry_data_repair_detail_worker_max_concurrency >= 0', + CONSTRAINT_NAME + end + + def down + return unless column_exists?(:application_settings, :container_registry_data_repair_detail_worker_max_concurrency) + + remove_check_constraint :application_settings, CONSTRAINT_NAME + + remove_column :application_settings, :container_registry_data_repair_detail_worker_max_concurrency + end +end diff --git a/db/post_migrate/20230301020356_swap_merge_request_user_mentions_note_id_to_bigint.rb b/db/post_migrate/20230301020356_swap_merge_request_user_mentions_note_id_to_bigint.rb index 11468a5844e..6a2aecbda98 100644 --- a/db/post_migrate/20230301020356_swap_merge_request_user_mentions_note_id_to_bigint.rb +++ b/db/post_migrate/20230301020356_swap_merge_request_user_mentions_note_id_to_bigint.rb @@ -1,83 +1,7 @@ # frozen_string_literal: true class SwapMergeRequestUserMentionsNoteIdToBigint < Gitlab::Database::Migration[2.1] - include Gitlab::Database::MigrationHelpers::ConvertToBigint - - disable_ddl_transaction! - - TABLE_NAME = 'merge_request_user_mentions' - - def up - return unless should_run? - - swap - end - - def down - return unless should_run? - - swap - - add_concurrent_index TABLE_NAME, :note_id_convert_to_bigint, unique: true, - name: 'index_merge_request_user_mentions_note_id_convert_to_bigint', - where: 'note_id_convert_to_bigint IS NOT NULL' - - add_concurrent_foreign_key TABLE_NAME, :notes, column: :note_id_convert_to_bigint, - name: 'fk_merge_request_user_mentions_note_id_convert_to_bigint', - on_delete: :cascade, - validate: false - end - - def swap - # This will replace the existing index_merge_request_user_mentions_on_note_id - add_concurrent_index TABLE_NAME, :note_id_convert_to_bigint, unique: true, - name: 'index_merge_request_user_mentions_note_id_convert_to_bigint', - where: 'note_id_convert_to_bigint IS NOT NULL' - - # This will replace the existing merge_request_user_mentions_on_mr_id_and_note_id_index - add_concurrent_index TABLE_NAME, [:merge_request_id, :note_id_convert_to_bigint], unique: true, - name: 'mr_user_mentions_on_mr_id_and_note_id_convert_to_bigint_index' - - # This will replace the existing merge_request_user_mentions_on_mr_id_index - add_concurrent_index TABLE_NAME, :merge_request_id, unique: true, - name: 'merge_request_user_mentions_on_mr_id_index_convert_to_bigint', - where: 'note_id_convert_to_bigint IS NULL' - - # This will replace the existing fk_rails_c440b9ea31 - add_concurrent_foreign_key TABLE_NAME, :notes, column: :note_id_convert_to_bigint, - name: 'fk_merge_request_user_mentions_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_merge_request_user_mentions_on_note_id' - rename_index TABLE_NAME, 'index_merge_request_user_mentions_note_id_convert_to_bigint', - 'index_merge_request_user_mentions_on_note_id' - - execute 'DROP INDEX IF EXISTS merge_request_user_mentions_on_mr_id_and_note_id_index' - rename_index TABLE_NAME, 'mr_user_mentions_on_mr_id_and_note_id_convert_to_bigint_index', - 'merge_request_user_mentions_on_mr_id_and_note_id_index' - - execute 'DROP INDEX IF EXISTS merge_request_user_mentions_on_mr_id_index' - rename_index TABLE_NAME, 'merge_request_user_mentions_on_mr_id_index_convert_to_bigint', - 'merge_request_user_mentions_on_mr_id_index' - - execute "ALTER TABLE #{TABLE_NAME} DROP CONSTRAINT IF EXISTS fk_rails_c440b9ea31" - rename_constraint(TABLE_NAME, 'fk_merge_request_user_mentions_note_id_convert_to_bigint', 'fk_rails_c440b9ea31') - end - end - - def should_run? - com_or_dev_or_test_but_not_jh? - end + # No-op, moved to db/post_migrate/20230310020356_swap_merge_request_user_mentions_note_id_to_bigint_2.rb + def up; end + def down; end end diff --git a/db/post_migrate/20230310020356_swap_merge_request_user_mentions_note_id_to_bigint_2.rb b/db/post_migrate/20230310020356_swap_merge_request_user_mentions_note_id_to_bigint_2.rb new file mode 100644 index 00000000000..c680b129493 --- /dev/null +++ b/db/post_migrate/20230310020356_swap_merge_request_user_mentions_note_id_to_bigint_2.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true + +class SwapMergeRequestUserMentionsNoteIdToBigint2 < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + disable_ddl_transaction! + + TABLE_NAME = 'merge_request_user_mentions' + + def up + return unless should_run? + return if columns_already_swapped? + + swap + end + + def down + return unless should_run? + return unless columns_already_swapped? + + swap + + add_concurrent_index TABLE_NAME, :note_id_convert_to_bigint, unique: true, + name: 'index_merge_request_user_mentions_note_id_convert_to_bigint', + where: 'note_id_convert_to_bigint IS NOT NULL' + + add_concurrent_foreign_key TABLE_NAME, :notes, column: :note_id_convert_to_bigint, + name: 'fk_merge_request_user_mentions_note_id_convert_to_bigint', + on_delete: :cascade, + validate: false + end + + def swap + # This will replace the existing index_merge_request_user_mentions_on_note_id + add_concurrent_index TABLE_NAME, :note_id_convert_to_bigint, unique: true, + name: 'index_merge_request_user_mentions_note_id_convert_to_bigint', + where: 'note_id_convert_to_bigint IS NOT NULL' + + # This will replace the existing merge_request_user_mentions_on_mr_id_and_note_id_index + add_concurrent_index TABLE_NAME, [:merge_request_id, :note_id_convert_to_bigint], unique: true, + name: 'mr_user_mentions_on_mr_id_and_note_id_convert_to_bigint_index' + + # This will replace the existing merge_request_user_mentions_on_mr_id_index + add_concurrent_index TABLE_NAME, :merge_request_id, unique: true, + name: 'merge_request_user_mentions_on_mr_id_index_convert_to_bigint', + where: 'note_id_convert_to_bigint IS NULL' + + # This will replace the existing fk_rails_c440b9ea31 + add_concurrent_foreign_key TABLE_NAME, :notes, column: :note_id_convert_to_bigint, + name: 'fk_merge_request_user_mentions_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_merge_request_user_mentions_on_note_id' + rename_index TABLE_NAME, 'index_merge_request_user_mentions_note_id_convert_to_bigint', + 'index_merge_request_user_mentions_on_note_id' + + execute 'DROP INDEX IF EXISTS merge_request_user_mentions_on_mr_id_and_note_id_index' + rename_index TABLE_NAME, 'mr_user_mentions_on_mr_id_and_note_id_convert_to_bigint_index', + 'merge_request_user_mentions_on_mr_id_and_note_id_index' + + execute 'DROP INDEX IF EXISTS merge_request_user_mentions_on_mr_id_index' + rename_index TABLE_NAME, 'merge_request_user_mentions_on_mr_id_index_convert_to_bigint', + 'merge_request_user_mentions_on_mr_id_index' + + execute "ALTER TABLE #{TABLE_NAME} DROP CONSTRAINT IF EXISTS fk_rails_c440b9ea31" + rename_constraint(TABLE_NAME, 'fk_merge_request_user_mentions_note_id_convert_to_bigint', 'fk_rails_c440b9ea31') + end + end + + def should_run? + com_or_dev_or_test_but_not_jh? + end + + def columns_already_swapped? + table_columns = columns(TABLE_NAME) + note_id = table_columns.find { |c| c.name == 'note_id' } + note_id_convert_to_bigint = table_columns.find { |c| c.name == 'note_id_convert_to_bigint' } + + note_id_convert_to_bigint.sql_type == 'integer' && note_id.sql_type == 'bigint' + end +end diff --git a/db/post_migrate/20230413041917_swap_issue_user_mentions_note_id_to_bigint_for_gitlab_dot_com_2.rb b/db/post_migrate/20230413041917_swap_issue_user_mentions_note_id_to_bigint_for_gitlab_dot_com_2.rb index cb29b47a64d..cf6736fb6c1 100644 --- a/db/post_migrate/20230413041917_swap_issue_user_mentions_note_id_to_bigint_for_gitlab_dot_com_2.rb +++ b/db/post_migrate/20230413041917_swap_issue_user_mentions_note_id_to_bigint_for_gitlab_dot_com_2.rb @@ -9,14 +9,14 @@ class SwapIssueUserMentionsNoteIdToBigintForGitlabDotCom2 < Gitlab::Database::Mi def up return unless should_run? - return if columns_alredy_swapped? + return if columns_already_swapped? swap end def down return unless should_run? - return unless columns_alredy_swapped? + return unless columns_already_swapped? swap @@ -83,7 +83,7 @@ class SwapIssueUserMentionsNoteIdToBigintForGitlabDotCom2 < Gitlab::Database::Mi com_or_dev_or_test_but_not_jh? end - def columns_alredy_swapped? + def columns_already_swapped? table_columns = columns(TABLE_NAME) note_id = table_columns.find { |c| c.name == 'note_id' } note_id_convert_to_bigint = table_columns.find { |c| c.name == 'note_id_convert_to_bigint' } diff --git a/db/post_migrate/20230510013754_cleanup_notes_bigint_preparation.rb b/db/post_migrate/20230510013754_cleanup_notes_bigint_preparation.rb new file mode 100644 index 00000000000..b2b898059b8 --- /dev/null +++ b/db/post_migrate/20230510013754_cleanup_notes_bigint_preparation.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +class CleanupNotesBigintPreparation < Gitlab::Database::Migration[2.1] + include Gitlab::Database::MigrationHelpers::ConvertToBigint + + disable_ddl_transaction! + + def up + return unless should_run? + + remove_concurrent_index_by_name( + :merge_request_user_mentions, + :index_merge_request_user_mentions_note_id_convert_to_bigint, + if_exists: true + ) + + remove_concurrent_index_by_name( + :issue_user_mentions, + :index_issue_user_mentions_on_note_id_convert_to_bigint, + if_exists: true + ) + + with_lock_retries do + remove_foreign_key_if_exists( + :issue_user_mentions, + :notes, + name: :fk_issue_user_mentions_note_id_convert_to_bigint, + reverse_lock_order: true + ) + end + + with_lock_retries do + remove_foreign_key_if_exists( + :merge_request_user_mentions, + :notes, + name: :fk_merge_request_user_mentions_note_id_convert_to_bigint, + reverse_lock_order: true + ) + end + end + + def down + # No-op + end + + private + + def should_run? + com_or_dev_or_test_but_not_jh? + end +end diff --git a/db/post_migrate/20230523125245_remove_project_ci_cd_setting_opt_in_jwt_column.rb b/db/post_migrate/20230523125245_remove_project_ci_cd_setting_opt_in_jwt_column.rb new file mode 100644 index 00000000000..7f7d58edc1b --- /dev/null +++ b/db/post_migrate/20230523125245_remove_project_ci_cd_setting_opt_in_jwt_column.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class RemoveProjectCiCdSettingOptInJwtColumn < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def up + remove_column(:project_ci_cd_settings, :opt_in_jwt) + end + + def down + # rubocop:disable Migration/SchemaAdditionMethodsNoPost + add_column(:project_ci_cd_settings, :opt_in_jwt, :boolean, default: false, null: false, if_not_exists: true) + # rubocop:enable Migration/SchemaAdditionMethodsNoPost + end +end diff --git a/db/post_migrate/20230525180605_add_index_work_item_types_on_base_type_id.rb b/db/post_migrate/20230525180605_add_index_work_item_types_on_base_type_id.rb new file mode 100644 index 00000000000..620153f2a7b --- /dev/null +++ b/db/post_migrate/20230525180605_add_index_work_item_types_on_base_type_id.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddIndexWorkItemTypesOnBaseTypeId < Gitlab::Database::Migration[2.1] + INDEX_NAME = 'index_work_item_types_on_base_type_and_id' + + disable_ddl_transaction! + + def up + add_concurrent_index :work_item_types, [:base_type, :id], name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :work_item_types, INDEX_NAME + end +end diff --git a/db/schema_migrations/20230310020356 b/db/schema_migrations/20230310020356 new file mode 100644 index 00000000000..ac942e2ec1a --- /dev/null +++ b/db/schema_migrations/20230310020356 @@ -0,0 +1 @@ +0b6ca48a68c9695f0035d2dd111707d3abaee7f260549a694250527c1f6f5b9e
\ No newline at end of file diff --git a/db/schema_migrations/20230510013754 b/db/schema_migrations/20230510013754 new file mode 100644 index 00000000000..f59495e6ff6 --- /dev/null +++ b/db/schema_migrations/20230510013754 @@ -0,0 +1 @@ +ee83bf5d8c283d1d24f4f7300abd0bb96e51ecfef480cab3a74875ebecf5cbcd
\ No newline at end of file diff --git a/db/schema_migrations/20230516183736 b/db/schema_migrations/20230516183736 new file mode 100644 index 00000000000..1e7ccb7c015 --- /dev/null +++ b/db/schema_migrations/20230516183736 @@ -0,0 +1 @@ +ccdbefaed7b3e32082ac2c4c49af1fcdf6d9c317739e6e67cc41156ed92404cf
\ No newline at end of file diff --git a/db/schema_migrations/20230523125245 b/db/schema_migrations/20230523125245 new file mode 100644 index 00000000000..bfb22be77dd --- /dev/null +++ b/db/schema_migrations/20230523125245 @@ -0,0 +1 @@ +1379d0f878297bd4815cbb2d58bc0187b9bb3609bdeb87ab20983682f1abfa55
\ No newline at end of file diff --git a/db/schema_migrations/20230525180605 b/db/schema_migrations/20230525180605 new file mode 100644 index 00000000000..19a40a0d20d --- /dev/null +++ b/db/schema_migrations/20230525180605 @@ -0,0 +1 @@ +004443f655b7fd50d161cd529839925b446a9aba6f62d58d710379b91ed72f1d
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 440e5a3e086..123cf711672 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -11841,6 +11841,7 @@ CREATE TABLE application_settings ( vertex_project text, wiki_asciidoc_allow_uri_includes boolean DEFAULT false NOT NULL, namespace_aggregation_schedule_lease_duration_in_seconds integer DEFAULT 300 NOT NULL, + container_registry_data_repair_detail_worker_max_concurrency integer DEFAULT 2 NOT NULL, CONSTRAINT app_settings_container_reg_cleanup_tags_max_list_size_positive CHECK ((container_registry_cleanup_tags_service_max_list_size >= 0)), CONSTRAINT app_settings_container_registry_pre_import_tags_rate_positive CHECK ((container_registry_pre_import_tags_rate >= (0)::numeric)), CONSTRAINT app_settings_dep_proxy_ttl_policies_worker_capacity_positive CHECK ((dependency_proxy_ttl_group_policy_worker_capacity >= 0)), @@ -11852,6 +11853,7 @@ CREATE TABLE application_settings ( CONSTRAINT app_settings_p_cleanup_package_file_worker_capacity_positive CHECK ((packages_cleanup_package_file_worker_capacity >= 0)), CONSTRAINT app_settings_pkg_registry_cleanup_pol_worker_capacity_gte_zero CHECK ((package_registry_cleanup_policies_worker_capacity >= 0)), CONSTRAINT app_settings_registry_exp_policies_worker_capacity_positive CHECK ((container_registry_expiration_policies_worker_capacity >= 0)), + CONSTRAINT app_settings_registry_repair_worker_max_concurrency_positive CHECK ((container_registry_data_repair_detail_worker_max_concurrency >= 0)), CONSTRAINT app_settings_yaml_max_depth_positive CHECK ((max_yaml_depth > 0)), CONSTRAINT app_settings_yaml_max_size_positive CHECK ((max_yaml_size_bytes > 0)), CONSTRAINT check_17d9558205 CHECK ((char_length((kroki_url)::text) <= 1024)), @@ -20723,7 +20725,6 @@ CREATE TABLE project_ci_cd_settings ( job_token_scope_enabled boolean DEFAULT false NOT NULL, runner_token_expiration_interval integer, separated_caches boolean DEFAULT true NOT NULL, - opt_in_jwt boolean DEFAULT false NOT NULL, allow_fork_pipelines_to_run_in_parent_project boolean DEFAULT true NOT NULL, inbound_job_token_scope_enabled boolean DEFAULT true NOT NULL ); @@ -33040,6 +33041,8 @@ CREATE UNIQUE INDEX index_work_item_parent_links_on_work_item_id ON work_item_pa CREATE INDEX index_work_item_parent_links_on_work_item_parent_id ON work_item_parent_links USING btree (work_item_parent_id); +CREATE INDEX index_work_item_types_on_base_type_and_id ON work_item_types USING btree (base_type, id); + CREATE UNIQUE INDEX index_work_item_widget_definitions_on_default_witype_and_name ON work_item_widget_definitions USING btree (work_item_type_id, name) WHERE (namespace_id IS NULL); CREATE UNIQUE INDEX index_work_item_widget_definitions_on_namespace_type_and_name ON work_item_widget_definitions USING btree (namespace_id, work_item_type_id, name); |