diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-26 00:10:26 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-26 00:10:26 +0300 |
commit | c0bc55ffe14525ff453a8bfe5a88ee87d3b615f1 (patch) | |
tree | a8e1dac4f7b45d6a2c397b73e1eba92b8505dd9c /db | |
parent | a880341a7b3a164ba381620852cc3ea0777f67ad (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
9 files changed, 153 insertions, 1 deletions
diff --git a/db/migrate/20210506150833_create_vulnerability_finding_evidence_headers.rb b/db/migrate/20210506150833_create_vulnerability_finding_evidence_headers.rb new file mode 100644 index 00000000000..0e584303e51 --- /dev/null +++ b/db/migrate/20210506150833_create_vulnerability_finding_evidence_headers.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class CreateVulnerabilityFindingEvidenceHeaders < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + create_table_with_constraints :vulnerability_finding_evidence_headers do |t| + t.timestamps_with_timezone null: false + + t.references :vulnerability_finding_evidence_request, index: { name: 'finding_evidence_header_on_finding_evidence_request_id' }, null: true, foreign_key: { on_delete: :cascade } + t.references :vulnerability_finding_evidence_response, index: { name: 'finding_evidence_header_on_finding_evidence_response_id' }, null: true, foreign_key: { on_delete: :cascade } + t.text :name, null: false + t.text :value, null: false + + t.text_limit :name, 255 + t.text_limit :value, 8192 + end + end + + def down + with_lock_retries do + drop_table :vulnerability_finding_evidence_headers + end + end +end diff --git a/db/migrate/20210520133032_initialize_conversion_of_taggings_to_bigint.rb b/db/migrate/20210520133032_initialize_conversion_of_taggings_to_bigint.rb new file mode 100644 index 00000000000..e154c25b082 --- /dev/null +++ b/db/migrate/20210520133032_initialize_conversion_of_taggings_to_bigint.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class InitializeConversionOfTaggingsToBigint < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + TABLE = :taggings + COLUMNS = %i(id taggable_id) + + def up + initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end + + def down + revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end +end diff --git a/db/migrate/20210520133440_backfill_taggings_for_bigint_conversion.rb b/db/migrate/20210520133440_backfill_taggings_for_bigint_conversion.rb new file mode 100644 index 00000000000..63ac308e4be --- /dev/null +++ b/db/migrate/20210520133440_backfill_taggings_for_bigint_conversion.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class BackfillTaggingsForBigintConversion < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + TABLE = :taggings + COLUMNS = %i(id taggable_id) + + def up + backfill_conversion_of_integer_to_bigint TABLE, COLUMNS, batch_size: 15000, sub_batch_size: 100 + end + + def down + revert_backfill_conversion_of_integer_to_bigint TABLE, COLUMNS + end +end diff --git a/db/post_migrate/20210426225417_schedule_recalculate_uuid_on_vulnerabilities_occurrences2.rb b/db/post_migrate/20210426225417_schedule_recalculate_uuid_on_vulnerabilities_occurrences2.rb new file mode 100644 index 00000000000..96eea2d5d77 --- /dev/null +++ b/db/post_migrate/20210426225417_schedule_recalculate_uuid_on_vulnerabilities_occurrences2.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +class ScheduleRecalculateUuidOnVulnerabilitiesOccurrences2 < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + MIGRATION = 'RecalculateVulnerabilitiesOccurrencesUuid' + DELAY_INTERVAL = 2.minutes.to_i + BATCH_SIZE = 2_500 + + disable_ddl_transaction! + + class VulnerabilitiesFinding < ActiveRecord::Base + include ::EachBatch + self.inheritance_column = :_type_disabled + + self.table_name = "vulnerability_occurrences" + end + + def up + # Make sure that RemoveDuplicateVulnerabilitiesFindings has finished running + # so that we don't run into duplicate UUID issues + Gitlab::BackgroundMigration.steal('RemoveDuplicateVulnerabilitiesFindings') + + say "Scheduling #{MIGRATION} jobs" + queue_background_migration_jobs_by_range_at_intervals( + VulnerabilitiesFinding, + MIGRATION, + DELAY_INTERVAL, + batch_size: BATCH_SIZE, + track_jobs: true + ) + end + + def down + # no-op + end +end diff --git a/db/schema_migrations/20210426225417 b/db/schema_migrations/20210426225417 new file mode 100644 index 00000000000..2ba6e666520 --- /dev/null +++ b/db/schema_migrations/20210426225417 @@ -0,0 +1 @@ +50d370d2465fa4c0d3c2bd963d5745474ca35a43609d0e754f3fe69eb7a7179f
\ No newline at end of file diff --git a/db/schema_migrations/20210506150833 b/db/schema_migrations/20210506150833 new file mode 100644 index 00000000000..e63559fee8a --- /dev/null +++ b/db/schema_migrations/20210506150833 @@ -0,0 +1 @@ +18fdca797ea7f3a60ce5b421bec7af1ea0b0b73fbf6e1c23592acbc9d13a0a52
\ No newline at end of file diff --git a/db/schema_migrations/20210520133032 b/db/schema_migrations/20210520133032 new file mode 100644 index 00000000000..169203e33cd --- /dev/null +++ b/db/schema_migrations/20210520133032 @@ -0,0 +1 @@ +eddbcd18c17f9017a2cdfb6fc0144dcfcb539d3617271722b2918bdbe48c481a
\ No newline at end of file diff --git a/db/schema_migrations/20210520133440 b/db/schema_migrations/20210520133440 new file mode 100644 index 00000000000..d5644ab8927 --- /dev/null +++ b/db/schema_migrations/20210520133440 @@ -0,0 +1 @@ +3ee15db28406522a5fb591395dd3d4a46b10e958339dc60ded3751e23096864d
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 7e2a540c6f1..6dfa80f16fd 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -170,6 +170,16 @@ BEGIN END; $$; +CREATE FUNCTION trigger_aebe8b822ad3() RETURNS trigger + LANGUAGE plpgsql + AS $$ +BEGIN + NEW."id_convert_to_bigint" := NEW."id"; + NEW."taggable_id_convert_to_bigint" := NEW."taggable_id"; + RETURN NEW; +END; +$$; + CREATE FUNCTION trigger_be1804f21693() RETURNS trigger LANGUAGE plpgsql AS $$ @@ -18218,7 +18228,9 @@ CREATE TABLE taggings ( tagger_id integer, tagger_type character varying, context character varying, - created_at timestamp without time zone + created_at timestamp without time zone, + id_convert_to_bigint bigint DEFAULT 0 NOT NULL, + taggable_id_convert_to_bigint bigint ); CREATE SEQUENCE taggings_id_seq @@ -18924,6 +18936,27 @@ CREATE SEQUENCE vulnerability_feedback_id_seq ALTER SEQUENCE vulnerability_feedback_id_seq OWNED BY vulnerability_feedback.id; +CREATE TABLE vulnerability_finding_evidence_headers ( + id bigint NOT NULL, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + vulnerability_finding_evidence_request_id bigint, + vulnerability_finding_evidence_response_id bigint, + name text NOT NULL, + value text NOT NULL, + CONSTRAINT check_01d21e8d92 CHECK ((char_length(name) <= 255)), + CONSTRAINT check_3f9011f903 CHECK ((char_length(value) <= 8192)) +); + +CREATE SEQUENCE vulnerability_finding_evidence_headers_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE vulnerability_finding_evidence_headers_id_seq OWNED BY vulnerability_finding_evidence_headers.id; + CREATE TABLE vulnerability_finding_evidence_requests ( id bigint NOT NULL, created_at timestamp with time zone NOT NULL, @@ -20299,6 +20332,8 @@ ALTER TABLE ONLY vulnerability_external_issue_links ALTER COLUMN id SET DEFAULT ALTER TABLE ONLY vulnerability_feedback ALTER COLUMN id SET DEFAULT nextval('vulnerability_feedback_id_seq'::regclass); +ALTER TABLE ONLY vulnerability_finding_evidence_headers ALTER COLUMN id SET DEFAULT nextval('vulnerability_finding_evidence_headers_id_seq'::regclass); + ALTER TABLE ONLY vulnerability_finding_evidence_requests ALTER COLUMN id SET DEFAULT nextval('vulnerability_finding_evidence_requests_id_seq'::regclass); ALTER TABLE ONLY vulnerability_finding_evidence_responses ALTER COLUMN id SET DEFAULT nextval('vulnerability_finding_evidence_responses_id_seq'::regclass); @@ -21981,6 +22016,9 @@ ALTER TABLE ONLY vulnerability_external_issue_links ALTER TABLE ONLY vulnerability_feedback ADD CONSTRAINT vulnerability_feedback_pkey PRIMARY KEY (id); +ALTER TABLE ONLY vulnerability_finding_evidence_headers + ADD CONSTRAINT vulnerability_finding_evidence_headers_pkey PRIMARY KEY (id); + ALTER TABLE ONLY vulnerability_finding_evidence_requests ADD CONSTRAINT vulnerability_finding_evidence_requests_pkey PRIMARY KEY (id); @@ -22221,6 +22259,10 @@ CREATE UNIQUE INDEX epic_user_mentions_on_epic_id_and_note_id_index ON epic_user CREATE UNIQUE INDEX epic_user_mentions_on_epic_id_index ON epic_user_mentions USING btree (epic_id) WHERE (note_id IS NULL); +CREATE INDEX finding_evidence_header_on_finding_evidence_request_id ON vulnerability_finding_evidence_headers USING btree (vulnerability_finding_evidence_request_id); + +CREATE INDEX finding_evidence_header_on_finding_evidence_response_id ON vulnerability_finding_evidence_headers USING btree (vulnerability_finding_evidence_response_id); + CREATE INDEX finding_evidence_requests_on_finding_evidence_id ON vulnerability_finding_evidence_requests USING btree (vulnerability_finding_evidence_id); CREATE INDEX finding_evidence_responses_on_finding_evidences_id ON vulnerability_finding_evidence_responses USING btree (vulnerability_finding_evidence_id); @@ -25263,6 +25305,8 @@ CREATE TRIGGER trigger_8487d4de3e7b BEFORE INSERT OR UPDATE ON ci_builds_metadat CREATE TRIGGER trigger_91dc388a5fe6 BEFORE INSERT OR UPDATE ON ci_build_trace_sections FOR EACH ROW EXECUTE FUNCTION trigger_91dc388a5fe6(); +CREATE TRIGGER trigger_aebe8b822ad3 BEFORE INSERT OR UPDATE ON taggings FOR EACH ROW EXECUTE FUNCTION trigger_aebe8b822ad3(); + CREATE TRIGGER trigger_be1804f21693 BEFORE INSERT OR UPDATE ON ci_job_artifacts FOR EACH ROW EXECUTE FUNCTION trigger_be1804f21693(); CREATE TRIGGER trigger_cf2f9e35f002 BEFORE INSERT OR UPDATE ON ci_build_trace_chunks FOR EACH ROW EXECUTE FUNCTION trigger_cf2f9e35f002(); @@ -26710,6 +26754,9 @@ ALTER TABLE ONLY vulnerability_findings_remediations ALTER TABLE ONLY resource_iteration_events ADD CONSTRAINT fk_rails_6830c13ac1 FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE; +ALTER TABLE ONLY vulnerability_finding_evidence_headers + ADD CONSTRAINT fk_rails_683b8e000c FOREIGN KEY (vulnerability_finding_evidence_response_id) REFERENCES vulnerability_finding_evidence_responses(id) ON DELETE CASCADE; + ALTER TABLE ONLY geo_hashed_storage_migrated_events ADD CONSTRAINT fk_rails_687ed7d7c5 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; @@ -27280,6 +27327,9 @@ ALTER TABLE ONLY operations_strategies_user_lists ALTER TABLE ONLY issue_tracker_data ADD CONSTRAINT fk_rails_ccc0840427 FOREIGN KEY (service_id) REFERENCES services(id) ON DELETE CASCADE; +ALTER TABLE ONLY vulnerability_finding_evidence_headers + ADD CONSTRAINT fk_rails_ce7f121a03 FOREIGN KEY (vulnerability_finding_evidence_request_id) REFERENCES vulnerability_finding_evidence_requests(id) ON DELETE CASCADE; + ALTER TABLE ONLY resource_milestone_events ADD CONSTRAINT fk_rails_cedf8cce4d FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL; |