diff options
Diffstat (limited to 'db')
9 files changed, 81 insertions, 3 deletions
diff --git a/db/post_migrate/20221121155850_change_vulnerabilities_state_transitions_comment_limit.rb b/db/post_migrate/20221121155850_change_vulnerabilities_state_transitions_comment_limit.rb new file mode 100644 index 00000000000..b75216ee413 --- /dev/null +++ b/db/post_migrate/20221121155850_change_vulnerabilities_state_transitions_comment_limit.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class ChangeVulnerabilitiesStateTransitionsCommentLimit < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + def up + add_text_limit( + :vulnerability_state_transitions, + :comment, + 50_000, + constraint_name: check_constraint_name(:vulnerability_state_transitions, :comment, 'max_length_50000') + ) + remove_text_limit( + :vulnerability_state_transitions, + :comment, + constraint_name: 'check_fca4a7ca39' + ) + end + + def down + # no-op: this can fail if records with length > 255 (previous limit) show up + end +end diff --git a/db/post_migrate/20221122155149_add_index_for_paths_on_non_projects.rb b/db/post_migrate/20221122155149_add_index_for_paths_on_non_projects.rb new file mode 100644 index 00000000000..e9a90844550 --- /dev/null +++ b/db/post_migrate/20221122155149_add_index_for_paths_on_non_projects.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddIndexForPathsOnNonProjects < Gitlab::Database::Migration[2.0] + TABLE_NAME = 'namespaces' + INDEX_NAME = 'index_namespaces_on_path_for_top_level_non_projects' + COLUMN = "(lower(path::text))" + CONDITIONS = "(parent_id IS NULL AND type::text <> 'Project'::text)" + + def up + prepare_async_index TABLE_NAME, COLUMN, name: INDEX_NAME, where: CONDITIONS + end + + def down + unprepare_async_index TABLE_NAME, COLUMN, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20221125222221_add_metrics_index_to_authentication_events.rb b/db/post_migrate/20221125222221_add_metrics_index_to_authentication_events.rb new file mode 100644 index 00000000000..2d3181dea67 --- /dev/null +++ b/db/post_migrate/20221125222221_add_metrics_index_to_authentication_events.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddMetricsIndexToAuthenticationEvents < Gitlab::Database::Migration[2.0] + INDEX_NAME = 'index_successful_authentication_events_for_metrics' + disable_ddl_transaction! + + def up + add_concurrent_index :authentication_events, + %i[user_id provider created_at], + where: "result = 1", + name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :authentication_events, INDEX_NAME + end +end diff --git a/db/post_migrate/20221125222341_remove_result_index_from_authentication_events.rb b/db/post_migrate/20221125222341_remove_result_index_from_authentication_events.rb new file mode 100644 index 00000000000..97fb4b320d1 --- /dev/null +++ b/db/post_migrate/20221125222341_remove_result_index_from_authentication_events.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class RemoveResultIndexFromAuthenticationEvents < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + INDEX_NAME = 'index_authentication_events_on_provider_user_id_created_at' + + def up + remove_concurrent_index_by_name :authentication_events, INDEX_NAME + end + + def down + add_concurrent_index :authentication_events, + [:provider, :user_id, :created_at], + where: 'result = 1', + name: INDEX_NAME + end +end diff --git a/db/schema_migrations/20221121155850 b/db/schema_migrations/20221121155850 new file mode 100644 index 00000000000..33c41d1b35e --- /dev/null +++ b/db/schema_migrations/20221121155850 @@ -0,0 +1 @@ +f73bd76a9ad54932b1f4b880af225a49089fc6ea782d213a9fc608b3029cddab
\ No newline at end of file diff --git a/db/schema_migrations/20221122155149 b/db/schema_migrations/20221122155149 new file mode 100644 index 00000000000..46a4270e5ed --- /dev/null +++ b/db/schema_migrations/20221122155149 @@ -0,0 +1 @@ +3c9b8f6191297e95c47a0ae2e3da7725ce33daa2a702407e0256393774935b0b
\ No newline at end of file diff --git a/db/schema_migrations/20221125222221 b/db/schema_migrations/20221125222221 new file mode 100644 index 00000000000..9235ef557b7 --- /dev/null +++ b/db/schema_migrations/20221125222221 @@ -0,0 +1 @@ +c1974d6763a85469f3d12fe4e51b1bc3b986cc335b7fe79b3875332d34a1b548
\ No newline at end of file diff --git a/db/schema_migrations/20221125222341 b/db/schema_migrations/20221125222341 new file mode 100644 index 00000000000..5f4a29202e1 --- /dev/null +++ b/db/schema_migrations/20221125222341 @@ -0,0 +1 @@ +401b563cf9f92627082bbc9850ab2fbe1d9806ced094fda99783c5d51e00fe1c
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 766a5a738b0..33a261fb753 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -23254,7 +23254,7 @@ CREATE TABLE vulnerability_state_transitions ( comment text, dismissal_reason smallint, CONSTRAINT check_d1ca8ec043 CHECK ((from_state <> to_state)), - CONSTRAINT check_fca4a7ca39 CHECK ((char_length(comment) <= 255)) + CONSTRAINT check_fe2eb6a0f3 CHECK ((char_length(comment) <= 50000)) ); CREATE SEQUENCE vulnerability_state_transitions_id_seq @@ -28382,8 +28382,6 @@ CREATE UNIQUE INDEX index_audit_events_external_audit_on_verification_token ON a CREATE INDEX index_authentication_events_on_provider ON authentication_events USING btree (provider); -CREATE INDEX index_authentication_events_on_provider_user_id_created_at ON authentication_events USING btree (provider, user_id, created_at) WHERE (result = 1); - CREATE INDEX index_authentication_events_on_user_and_ip_address_and_result ON authentication_events USING btree (user_id, ip_address, result); CREATE INDEX index_award_emoji_on_awardable_type_and_awardable_id ON award_emoji USING btree (awardable_type, awardable_id); @@ -30942,6 +30940,8 @@ CREATE INDEX index_subscriptions_on_project_id ON subscriptions USING btree (pro CREATE UNIQUE INDEX index_subscriptions_on_subscribable_and_user_id_and_project_id ON subscriptions USING btree (subscribable_id, subscribable_type, user_id, project_id); +CREATE INDEX index_successful_authentication_events_for_metrics ON authentication_events USING btree (user_id, provider, created_at) WHERE (result = 1); + CREATE INDEX index_successful_deployments_on_cluster_id_and_environment_id ON deployments USING btree (cluster_id, environment_id) WHERE (status = 2); CREATE UNIQUE INDEX index_suggestions_on_note_id_and_relative_order ON suggestions USING btree (note_id, relative_order); |