diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-17 15:10:15 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-17 15:10:15 +0000 |
commit | 68c476dbd8a2c670aeeebffce8b63b554a3ac7f0 (patch) | |
tree | c46b90a5c131d8e8d7fb530f1b8f9390b8eb2613 /db | |
parent | a62238de7302e54edafa3407a2dc8ba1a5f96e4d (diff) | |
download | gitlab-ce-68c476dbd8a2c670aeeebffce8b63b554a3ac7f0.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20210430122951_add_snapshot_namespace_id.rb | 7 | ||||
-rw-r--r-- | db/migrate/20210430124212_add_display_namespace_id_to_segments.rb | 7 | ||||
-rw-r--r-- | db/migrate/20210430124630_add_devops_adoption_indexes.rb | 32 | ||||
-rw-r--r-- | db/post_migrate/20210430130259_remove_obsolete_segments_field.rb | 18 | ||||
-rw-r--r-- | db/post_migrate/20210430134202_copy_adoption_snapshot_namespace.rb | 16 | ||||
-rw-r--r-- | db/post_migrate/20210430135954_copy_adoption_segments_namespace.rb | 14 | ||||
-rw-r--r-- | db/post_migrate/20210511051718_create_index_on_notes_note.rb | 26 | ||||
-rw-r--r-- | db/schema_migrations/20210430122951 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20210430124212 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20210430124630 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20210430130259 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20210430134202 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20210430135954 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20210511051718 | 1 | ||||
-rw-r--r-- | db/structure.sql | 20 |
15 files changed, 143 insertions, 4 deletions
diff --git a/db/migrate/20210430122951_add_snapshot_namespace_id.rb b/db/migrate/20210430122951_add_snapshot_namespace_id.rb new file mode 100644 index 00000000000..9017bcdde53 --- /dev/null +++ b/db/migrate/20210430122951_add_snapshot_namespace_id.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddSnapshotNamespaceId < ActiveRecord::Migration[6.0] + def change + add_column :analytics_devops_adoption_snapshots, :namespace_id, :integer + end +end diff --git a/db/migrate/20210430124212_add_display_namespace_id_to_segments.rb b/db/migrate/20210430124212_add_display_namespace_id_to_segments.rb new file mode 100644 index 00000000000..43be5c719fb --- /dev/null +++ b/db/migrate/20210430124212_add_display_namespace_id_to_segments.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddDisplayNamespaceIdToSegments < ActiveRecord::Migration[6.0] + def change + add_column :analytics_devops_adoption_segments, :display_namespace_id, :integer + end +end diff --git a/db/migrate/20210430124630_add_devops_adoption_indexes.rb b/db/migrate/20210430124630_add_devops_adoption_indexes.rb new file mode 100644 index 00000000000..4531e6b5e4c --- /dev/null +++ b/db/migrate/20210430124630_add_devops_adoption_indexes.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +class AddDevopsAdoptionIndexes < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + SEGMENTS_INDEX_NAME = 'idx_devops_adoption_segments_namespaces_pair' + SNAPSHOT_END_TIME_INDEX_NAME = 'idx_devops_adoption_segments_namespace_end_time' + SNAPSHOT_RECORDED_AT_INDEX_NAME = 'idx_devops_adoption_segments_namespace_recorded_at' + + def up + add_concurrent_index :analytics_devops_adoption_snapshots, [:namespace_id, :end_time], + name: SNAPSHOT_END_TIME_INDEX_NAME + add_concurrent_index :analytics_devops_adoption_snapshots, [:namespace_id, :recorded_at], + name: SNAPSHOT_RECORDED_AT_INDEX_NAME + add_concurrent_index :analytics_devops_adoption_segments, [:display_namespace_id, :namespace_id], + unique: true, name: SEGMENTS_INDEX_NAME + + add_concurrent_foreign_key :analytics_devops_adoption_snapshots, :namespaces, column: :namespace_id + add_concurrent_foreign_key :analytics_devops_adoption_segments, :namespaces, column: :display_namespace_id + end + + def down + remove_foreign_key :analytics_devops_adoption_segments, :namespaces, column: :display_namespace_id + remove_foreign_key :analytics_devops_adoption_snapshots, :namespaces, column: :namespace_id + + remove_concurrent_index_by_name :analytics_devops_adoption_segments, SEGMENTS_INDEX_NAME + remove_concurrent_index_by_name :analytics_devops_adoption_snapshots, SNAPSHOT_RECORDED_AT_INDEX_NAME + remove_concurrent_index_by_name :analytics_devops_adoption_snapshots, SNAPSHOT_END_TIME_INDEX_NAME + end +end diff --git a/db/post_migrate/20210430130259_remove_obsolete_segments_field.rb b/db/post_migrate/20210430130259_remove_obsolete_segments_field.rb new file mode 100644 index 00000000000..ffdd84582cb --- /dev/null +++ b/db/post_migrate/20210430130259_remove_obsolete_segments_field.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class RemoveObsoleteSegmentsField < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + def up + with_lock_retries do + remove_column :analytics_devops_adoption_segments, :name + end + end + + def down + add_column :analytics_devops_adoption_segments, :name, :text + add_text_limit :analytics_devops_adoption_segments, :name, 255 + end +end diff --git a/db/post_migrate/20210430134202_copy_adoption_snapshot_namespace.rb b/db/post_migrate/20210430134202_copy_adoption_snapshot_namespace.rb new file mode 100644 index 00000000000..d0a72ff2c43 --- /dev/null +++ b/db/post_migrate/20210430134202_copy_adoption_snapshot_namespace.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class CopyAdoptionSnapshotNamespace < ActiveRecord::Migration[6.0] + def up + execute <<-SQL + UPDATE analytics_devops_adoption_snapshots snapshots + SET namespace_id = segments.namespace_id + FROM analytics_devops_adoption_segments segments + WHERE snapshots.namespace_id IS NULL AND segments.id = snapshots.segment_id + SQL + end + + def down + execute 'UPDATE analytics_devops_adoption_snapshots SET namespace_id = NULL' + end +end diff --git a/db/post_migrate/20210430135954_copy_adoption_segments_namespace.rb b/db/post_migrate/20210430135954_copy_adoption_segments_namespace.rb new file mode 100644 index 00000000000..04f454bea37 --- /dev/null +++ b/db/post_migrate/20210430135954_copy_adoption_segments_namespace.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class CopyAdoptionSegmentsNamespace < ActiveRecord::Migration[6.0] + def up + execute <<-SQL + UPDATE analytics_devops_adoption_segments SET display_namespace_id = namespace_id + WHERE display_namespace_id IS NULL + SQL + end + + def down + execute 'UPDATE analytics_devops_adoption_segments SET display_namespace_id = NULL' + end +end diff --git a/db/post_migrate/20210511051718_create_index_on_notes_note.rb b/db/post_migrate/20210511051718_create_index_on_notes_note.rb new file mode 100644 index 00000000000..8e0ccb3616b --- /dev/null +++ b/db/post_migrate/20210511051718_create_index_on_notes_note.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class CreateIndexOnNotesNote < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DUPLICATE_INDEX_NAME = 'index_notes_on_note_gin_trigram' + CURRENT_INDEX_NAME = 'index_notes_on_note_trigram' + + disable_ddl_transaction! + + # https://gitlab.com/gitlab-org/gitlab/-/issues/218410#note_565624409 + # We are having troubles with the index, and some inserts are taking a long time + # so in this migration we are recreating the index + def up + add_concurrent_index :notes, :note, name: DUPLICATE_INDEX_NAME, using: :gin, opclass: :gin_trgm_ops + remove_concurrent_index_by_name :notes, CURRENT_INDEX_NAME + end + + def down + add_concurrent_index :notes, :note, name: CURRENT_INDEX_NAME, using: :gin, opclass: :gin_trgm_ops + remove_concurrent_index_by_name :notes, DUPLICATE_INDEX_NAME + end +end diff --git a/db/schema_migrations/20210430122951 b/db/schema_migrations/20210430122951 new file mode 100644 index 00000000000..43c90a10f22 --- /dev/null +++ b/db/schema_migrations/20210430122951 @@ -0,0 +1 @@ +476dc70eae87ad3ee30e6be8c1afb4a2aec23a09b96daba2afbd9c4e2edb12b9
\ No newline at end of file diff --git a/db/schema_migrations/20210430124212 b/db/schema_migrations/20210430124212 new file mode 100644 index 00000000000..dd3e8c1f371 --- /dev/null +++ b/db/schema_migrations/20210430124212 @@ -0,0 +1 @@ +ebdeb56647f3a7ff5620141833c90b796a9ddfed39234bcf8063ca5b3df6c1f3
\ No newline at end of file diff --git a/db/schema_migrations/20210430124630 b/db/schema_migrations/20210430124630 new file mode 100644 index 00000000000..2366ab58ef4 --- /dev/null +++ b/db/schema_migrations/20210430124630 @@ -0,0 +1 @@ +7f6862205e8c315da8433083fc5391f8889951f62d466e0048063322a46f9cc7
\ No newline at end of file diff --git a/db/schema_migrations/20210430130259 b/db/schema_migrations/20210430130259 new file mode 100644 index 00000000000..b8064b30f52 --- /dev/null +++ b/db/schema_migrations/20210430130259 @@ -0,0 +1 @@ +c4a4b214f15a1a8d7f6832782d50077189281ca9a9b1b746a0a3bc3af4a47e3c
\ No newline at end of file diff --git a/db/schema_migrations/20210430134202 b/db/schema_migrations/20210430134202 new file mode 100644 index 00000000000..cb9eee98cc0 --- /dev/null +++ b/db/schema_migrations/20210430134202 @@ -0,0 +1 @@ +77e2b8c1c6054a80122f97dda1e843149fefb7bf6694fdfa897d691d61162d81
\ No newline at end of file diff --git a/db/schema_migrations/20210430135954 b/db/schema_migrations/20210430135954 new file mode 100644 index 00000000000..9e201905704 --- /dev/null +++ b/db/schema_migrations/20210430135954 @@ -0,0 +1 @@ +c5fe6f74822168599ad5069bb7c793ec96a4bba99d15ad29cb161ef24291b56d
\ No newline at end of file diff --git a/db/schema_migrations/20210511051718 b/db/schema_migrations/20210511051718 new file mode 100644 index 00000000000..cf6cb7c0ee9 --- /dev/null +++ b/db/schema_migrations/20210511051718 @@ -0,0 +1 @@ +2d11da499f49964f37cc0a2c541cf58182416ae7b6b0e762a135b327099de1a4
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 6ebfbf4409a..fac2cac7b06 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -9103,12 +9103,11 @@ ALTER SEQUENCE analytics_devops_adoption_segment_selections_id_seq OWNED BY anal CREATE TABLE analytics_devops_adoption_segments ( id bigint NOT NULL, - name text, last_recorded_at timestamp with time zone, created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL, namespace_id integer, - CONSTRAINT check_4be7a006fd CHECK ((char_length(name) <= 255)) + display_namespace_id integer ); CREATE SEQUENCE analytics_devops_adoption_segments_id_seq @@ -9133,7 +9132,8 @@ CREATE TABLE analytics_devops_adoption_snapshots ( security_scan_succeeded boolean NOT NULL, end_time timestamp with time zone NOT NULL, total_projects_count integer, - code_owners_used_count integer + code_owners_used_count integer, + namespace_id integer ); CREATE SEQUENCE analytics_devops_adoption_snapshots_id_seq @@ -22133,6 +22133,12 @@ CREATE INDEX idx_container_repositories_on_exp_cleanup_status_and_start_date ON CREATE INDEX idx_deployment_clusters_on_cluster_id_and_kubernetes_namespace ON deployment_clusters USING btree (cluster_id, kubernetes_namespace); +CREATE INDEX idx_devops_adoption_segments_namespace_end_time ON analytics_devops_adoption_snapshots USING btree (namespace_id, end_time); + +CREATE INDEX idx_devops_adoption_segments_namespace_recorded_at ON analytics_devops_adoption_snapshots USING btree (namespace_id, recorded_at); + +CREATE UNIQUE INDEX idx_devops_adoption_segments_namespaces_pair ON analytics_devops_adoption_segments USING btree (display_namespace_id, namespace_id); + CREATE INDEX idx_eaprpb_external_approval_rule_id ON external_approval_rules_protected_branches USING btree (external_approval_rule_id); CREATE INDEX idx_elastic_reindexing_slices_on_elastic_reindexing_subtask_id ON elastic_reindexing_slices USING btree (elastic_reindexing_subtask_id); @@ -23667,7 +23673,7 @@ CREATE INDEX index_notes_on_discussion_id ON notes USING btree (discussion_id); CREATE INDEX index_notes_on_line_code ON notes USING btree (line_code); -CREATE INDEX index_notes_on_note_trigram ON notes USING gin (note gin_trgm_ops); +CREATE INDEX index_notes_on_note_gin_trigram ON notes USING gin (note gin_trgm_ops); CREATE INDEX index_notes_on_noteable_id_and_noteable_type_and_system ON notes USING btree (noteable_id, noteable_type, system); @@ -25224,6 +25230,9 @@ ALTER TABLE ONLY project_features ALTER TABLE ONLY ci_pipelines ADD CONSTRAINT fk_190998ef09 FOREIGN KEY (external_pull_request_id) REFERENCES external_pull_requests(id) ON DELETE SET NULL; +ALTER TABLE ONLY analytics_devops_adoption_segments + ADD CONSTRAINT fk_190a24754d FOREIGN KEY (display_namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; + ALTER TABLE ONLY user_details ADD CONSTRAINT fk_190e4fcc88 FOREIGN KEY (provisioned_by_group_id) REFERENCES namespaces(id) ON DELETE SET NULL; @@ -25440,6 +25449,9 @@ ALTER TABLE ONLY users ALTER TABLE ONLY geo_event_log ADD CONSTRAINT fk_78a6492f68 FOREIGN KEY (repository_updated_event_id) REFERENCES geo_repository_updated_events(id) ON DELETE CASCADE; +ALTER TABLE ONLY analytics_devops_adoption_snapshots + ADD CONSTRAINT fk_78c9eac821 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; + ALTER TABLE ONLY lists ADD CONSTRAINT fk_7a5553d60f FOREIGN KEY (label_id) REFERENCES labels(id) ON DELETE CASCADE; |