diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-17 18:10:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-17 18:10:03 +0300 |
commit | 5c5e86aa5c6e8be8424a92846cd0dfa8e72944e2 (patch) | |
tree | 9047b132263f282626359e89c8656b48019a58ca /db | |
parent | 11cb5f046dddc630abd416593e176d65f6ba2b69 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
9 files changed, 104 insertions, 0 deletions
diff --git a/db/migrate/20210611101034_add_devops_adoption_sast_dast.rb b/db/migrate/20210611101034_add_devops_adoption_sast_dast.rb new file mode 100644 index 00000000000..0a9eb64a5fc --- /dev/null +++ b/db/migrate/20210611101034_add_devops_adoption_sast_dast.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class AddDevopsAdoptionSastDast < ActiveRecord::Migration[6.1] + def change + add_column :analytics_devops_adoption_snapshots, :sast_enabled_count, :integer + add_column :analytics_devops_adoption_snapshots, :dast_enabled_count, :integer + end +end diff --git a/db/migrate/20210614124111_add_devops_adoption_sast_dast_indexes.rb b/db/migrate/20210614124111_add_devops_adoption_sast_dast_indexes.rb new file mode 100644 index 00000000000..9d40fe30ed6 --- /dev/null +++ b/db/migrate/20210614124111_add_devops_adoption_sast_dast_indexes.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddDevopsAdoptionSastDastIndexes < ActiveRecord::Migration[6.1] + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + INDEX_SAST = 'index_ci_job_artifacts_sast_for_devops_adoption' + INDEX_DAST = 'index_ci_job_artifacts_dast_for_devops_adoption' + + def up + add_concurrent_index :ci_job_artifacts, [:project_id, :created_at], where: "file_type = 5", name: INDEX_SAST + add_concurrent_index :ci_job_artifacts, [:project_id, :created_at], where: "file_type = 8", name: INDEX_DAST + end + + def down + remove_concurrent_index_by_name :ci_job_artifacts, INDEX_SAST + remove_concurrent_index_by_name :ci_job_artifacts, INDEX_DAST + end +end diff --git a/db/post_migrate/20210609202501_schedule_backfill_draft_status_on_merge_requests.rb b/db/post_migrate/20210609202501_schedule_backfill_draft_status_on_merge_requests.rb new file mode 100644 index 00000000000..72c4168af50 --- /dev/null +++ b/db/post_migrate/20210609202501_schedule_backfill_draft_status_on_merge_requests.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +class ScheduleBackfillDraftStatusOnMergeRequests < ActiveRecord::Migration[6.1] + include Gitlab::Database::MigrationHelpers + + INDEX_NAME = "tmp_index_merge_requests_draft_and_status" + MIGRATION = 'BackfillDraftStatusOnMergeRequests' + DELAY_INTERVAL = 2.minutes + BATCH_SIZE = 100 + + disable_ddl_transaction! + + def up + add_concurrent_index :merge_requests, :id, + where: "draft = false AND state_id = 1 AND ((title)::text ~* '^\\[draft\\]|\\(draft\\)|draft:|draft|\\[WIP\\]|WIP:|WIP'::text)", + name: INDEX_NAME + + eligible_mrs = Gitlab::BackgroundMigration::BackfillDraftStatusOnMergeRequests::MergeRequest.eligible + + queue_background_migration_jobs_by_range_at_intervals( + eligible_mrs, + MIGRATION, + DELAY_INTERVAL, + track_jobs: true, + batch_size: BATCH_SIZE + ) + end + + def down + remove_concurrent_index_by_name :merge_requests, INDEX_NAME + end +end diff --git a/db/post_migrate/20210615234935_fix_batched_migrations_old_format_job_arguments.rb b/db/post_migrate/20210615234935_fix_batched_migrations_old_format_job_arguments.rb new file mode 100644 index 00000000000..535f7426938 --- /dev/null +++ b/db/post_migrate/20210615234935_fix_batched_migrations_old_format_job_arguments.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +class FixBatchedMigrationsOldFormatJobArguments < ActiveRecord::Migration[6.1] + class BatchedMigration < ActiveRecord::Base + self.table_name = 'batched_background_migrations' + end + + def up + # rubocop:disable Style/WordArray + [ + ['events', 'id', ['id', 'id_convert_to_bigint'], [['id'], ['id_convert_to_bigint']]], + ['push_event_payloads', 'event_id', ['event_id', 'event_id_convert_to_bigint'], [['event_id'], ['event_id_convert_to_bigint']]] + ].each do |table_name, column_name, legacy_job_arguments, current_job_arguments| + base_scope = BatchedMigration + .where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob', table_name: table_name, column_name: column_name) + # rubocop:enable Style/WordArray + + # rubocop:disable Rails/WhereEquals + base_scope + .where('job_arguments = ?', legacy_job_arguments.to_json) + .where('NOT EXISTS (?)', base_scope.select('1').where('job_arguments = ?', current_job_arguments.to_json)) + .update_all(job_arguments: current_job_arguments) + # rubocop:enable Rails/WhereEquals + end + end + + def down + # No-op, there is no way to know were the existing record migrated from + # legacy job arguments, or were using the current format from the start. + # There is no reason to go back anyway. + end +end diff --git a/db/schema_migrations/20210609202501 b/db/schema_migrations/20210609202501 new file mode 100644 index 00000000000..ad71feddcfc --- /dev/null +++ b/db/schema_migrations/20210609202501 @@ -0,0 +1 @@ +93f577e2fe2dcc0daafc4ff7e15a4511a2e9f86f05f9892f5c7625f11bfce3ae
\ No newline at end of file diff --git a/db/schema_migrations/20210611101034 b/db/schema_migrations/20210611101034 new file mode 100644 index 00000000000..70712a32be1 --- /dev/null +++ b/db/schema_migrations/20210611101034 @@ -0,0 +1 @@ +a535348229ff5e9e3c5b530ded9407df9f4308fc4d9967106bf246d7267c2a48
\ No newline at end of file diff --git a/db/schema_migrations/20210614124111 b/db/schema_migrations/20210614124111 new file mode 100644 index 00000000000..25427277070 --- /dev/null +++ b/db/schema_migrations/20210614124111 @@ -0,0 +1 @@ +30c6316f3931075bd8b167e06af5d80b7ece65f428d1fa7602ab27b526bc8410
\ No newline at end of file diff --git a/db/schema_migrations/20210615234935 b/db/schema_migrations/20210615234935 new file mode 100644 index 00000000000..83e43f74a53 --- /dev/null +++ b/db/schema_migrations/20210615234935 @@ -0,0 +1 @@ +205336e95a6e3c9fa8c56fa67e66ef3023ba8c6cd4e6f3599160b74b3fbfaa3c
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 6de556b602f..eee0b920a46 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -9114,6 +9114,8 @@ CREATE TABLE analytics_devops_adoption_snapshots ( total_projects_count integer, code_owners_used_count integer, namespace_id integer, + sast_enabled_count integer, + dast_enabled_count integer, CONSTRAINT check_3f472de131 CHECK ((namespace_id IS NOT NULL)) ); @@ -22833,6 +22835,8 @@ CREATE UNIQUE INDEX index_ci_group_variables_on_group_id_and_key_and_environment CREATE UNIQUE INDEX index_ci_instance_variables_on_key ON ci_instance_variables USING btree (key); +CREATE INDEX index_ci_job_artifacts_dast_for_devops_adoption ON ci_job_artifacts USING btree (project_id, created_at) WHERE (file_type = 8); + CREATE INDEX index_ci_job_artifacts_for_terraform_reports ON ci_job_artifacts USING btree (project_id, id) WHERE (file_type = 18); CREATE INDEX index_ci_job_artifacts_id_for_terraform_reports ON ci_job_artifacts USING btree (id) WHERE (file_type = 18); @@ -22847,6 +22851,8 @@ CREATE INDEX index_ci_job_artifacts_on_project_id ON ci_job_artifacts USING btre CREATE INDEX index_ci_job_artifacts_on_project_id_for_security_reports ON ci_job_artifacts USING btree (project_id) WHERE (file_type = ANY (ARRAY[5, 6, 7, 8])); +CREATE INDEX index_ci_job_artifacts_sast_for_devops_adoption ON ci_job_artifacts USING btree (project_id, created_at) WHERE (file_type = 5); + CREATE INDEX index_ci_job_token_project_scope_links_on_added_by_id ON ci_job_token_project_scope_links USING btree (added_by_id); CREATE INDEX index_ci_job_token_project_scope_links_on_target_project_id ON ci_job_token_project_scope_links USING btree (target_project_id); @@ -25143,6 +25149,8 @@ CREATE INDEX tmp_idx_deduplicate_vulnerability_occurrences ON vulnerability_occu CREATE INDEX tmp_idx_on_namespaces_delayed_project_removal ON namespaces USING btree (id) WHERE (delayed_project_removal = true); +CREATE INDEX tmp_index_merge_requests_draft_and_status ON merge_requests USING btree (id) WHERE ((draft = false) AND (state_id = 1) AND ((title)::text ~* '^\[draft\]|\(draft\)|draft:|draft|\[WIP\]|WIP:|WIP'::text)); + CREATE INDEX tmp_index_namespaces_empty_traversal_ids_with_child_namespaces ON namespaces USING btree (id) WHERE ((parent_id IS NOT NULL) AND (traversal_ids = '{}'::integer[])); CREATE INDEX tmp_index_namespaces_empty_traversal_ids_with_root_namespaces ON namespaces USING btree (id) WHERE ((parent_id IS NULL) AND (traversal_ids = '{}'::integer[])); |