Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-11-30 18:09:21 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-30 18:09:21 +0300
commit56eafa995d0bbda39bc24cd07537286bf36a4dd9 (patch)
treeb172c7a9b29e75851d9c20b07147efcebd768be1 /db
parentf66bb12f3879bf86387157af1e614c5e0e93e561 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20201112132808_create_bulk_import_failures.rb39
-rw-r--r--db/migrate/20201124075951_create_vulnerability_external_links.rb42
-rw-r--r--db/schema_migrations/202011121328081
-rw-r--r--db/schema_migrations/202011240759511
-rw-r--r--db/structure.sql77
5 files changed, 160 insertions, 0 deletions
diff --git a/db/migrate/20201112132808_create_bulk_import_failures.rb b/db/migrate/20201112132808_create_bulk_import_failures.rb
new file mode 100644
index 00000000000..cdc5a4d6ff0
--- /dev/null
+++ b/db/migrate/20201112132808_create_bulk_import_failures.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+class CreateBulkImportFailures < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ unless table_exists?(:bulk_import_failures)
+ create_table :bulk_import_failures do |t|
+ t.references :bulk_import_entity,
+ null: false,
+ index: true,
+ foreign_key: { on_delete: :cascade }
+
+ t.datetime_with_timezone :created_at, null: false
+ t.text :pipeline_class, null: false
+ t.text :exception_class, null: false
+ t.text :exception_message, null: false
+ t.text :correlation_id_value, index: true
+ end
+ end
+ end
+
+ add_text_limit :bulk_import_failures, :pipeline_class, 255
+ add_text_limit :bulk_import_failures, :exception_class, 255
+ add_text_limit :bulk_import_failures, :exception_message, 255
+ add_text_limit :bulk_import_failures, :correlation_id_value, 255
+ end
+
+ def down
+ with_lock_retries do
+ drop_table :bulk_import_failures
+ end
+ end
+end
diff --git a/db/migrate/20201124075951_create_vulnerability_external_links.rb b/db/migrate/20201124075951_create_vulnerability_external_links.rb
new file mode 100644
index 00000000000..8200b15559b
--- /dev/null
+++ b/db/migrate/20201124075951_create_vulnerability_external_links.rb
@@ -0,0 +1,42 @@
+# frozen_string_literal: true
+
+class CreateVulnerabilityExternalLinks < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ create_table :vulnerability_external_issue_links, if_not_exists: true do |t|
+ t.timestamps_with_timezone null: false
+ t.references :author, null: false, index: true, foreign_key: { to_table: :users, on_delete: :nullify }, type: :bigint
+ t.references :vulnerability, null: false, index: true, type: :bigint
+ t.integer :link_type, limit: 2, null: false, default: 1 # 'created'
+ t.integer :external_type, limit: 2, null: false, default: 1 # 'jira'
+ t.text :external_project_key, null: false
+ t.text :external_issue_key, null: false
+
+ t.index %i[vulnerability_id external_type external_project_key external_issue_key],
+ name: 'idx_vulnerability_ext_issue_links_on_vulne_id_and_ext_issue',
+ unique: true
+ t.index %i[vulnerability_id link_type],
+ name: 'idx_vulnerability_ext_issue_links_on_vulne_id_and_link_type',
+ where: 'link_type = 1',
+ unique: true # only one 'created' link per vulnerability is allowed
+ end
+ end
+
+ add_concurrent_foreign_key :vulnerability_external_issue_links, :vulnerabilities, column: :vulnerability_id, on_delete: :cascade
+
+ add_text_limit :vulnerability_external_issue_links, :external_project_key, 255
+ add_text_limit :vulnerability_external_issue_links, :external_issue_key, 255
+ end
+
+ def down
+ with_lock_retries do
+ drop_table :vulnerability_external_issue_links
+ end
+ end
+end
diff --git a/db/schema_migrations/20201112132808 b/db/schema_migrations/20201112132808
new file mode 100644
index 00000000000..d6cc9595c80
--- /dev/null
+++ b/db/schema_migrations/20201112132808
@@ -0,0 +1 @@
+2b30b1ba41a49ce4a81711e6fef1dbcdaf8b76f824aaf83702cd27833815e57b \ No newline at end of file
diff --git a/db/schema_migrations/20201124075951 b/db/schema_migrations/20201124075951
new file mode 100644
index 00000000000..b659c83ad21
--- /dev/null
+++ b/db/schema_migrations/20201124075951
@@ -0,0 +1 @@
+6779e92fa65ff206b19bb99a5a242e3ab5fd7a8d15be89dee925d1fbb5b00632 \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index 053cab899bb..beb05a5c5e6 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -9927,6 +9927,29 @@ CREATE SEQUENCE bulk_import_entities_id_seq
ALTER SEQUENCE bulk_import_entities_id_seq OWNED BY bulk_import_entities.id;
+CREATE TABLE bulk_import_failures (
+ id bigint NOT NULL,
+ bulk_import_entity_id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ pipeline_class text NOT NULL,
+ exception_class text NOT NULL,
+ exception_message text NOT NULL,
+ correlation_id_value text,
+ CONSTRAINT check_053d65c7a4 CHECK ((char_length(pipeline_class) <= 255)),
+ CONSTRAINT check_6eca8f972e CHECK ((char_length(exception_message) <= 255)),
+ CONSTRAINT check_c7dba8398e CHECK ((char_length(exception_class) <= 255)),
+ CONSTRAINT check_e787285882 CHECK ((char_length(correlation_id_value) <= 255))
+);
+
+CREATE SEQUENCE bulk_import_failures_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE bulk_import_failures_id_seq OWNED BY bulk_import_failures.id;
+
CREATE TABLE bulk_import_trackers (
id bigint NOT NULL,
bulk_import_entity_id bigint NOT NULL,
@@ -17231,6 +17254,29 @@ CREATE SEQUENCE vulnerability_exports_id_seq
ALTER SEQUENCE vulnerability_exports_id_seq OWNED BY vulnerability_exports.id;
+CREATE TABLE vulnerability_external_issue_links (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ author_id bigint NOT NULL,
+ vulnerability_id bigint NOT NULL,
+ link_type smallint DEFAULT 1 NOT NULL,
+ external_type smallint DEFAULT 1 NOT NULL,
+ external_project_key text NOT NULL,
+ external_issue_key text NOT NULL,
+ CONSTRAINT check_3200604f5e CHECK ((char_length(external_issue_key) <= 255)),
+ CONSTRAINT check_68cffd19b0 CHECK ((char_length(external_project_key) <= 255))
+);
+
+CREATE SEQUENCE vulnerability_external_issue_links_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE vulnerability_external_issue_links_id_seq OWNED BY vulnerability_external_issue_links.id;
+
CREATE TABLE vulnerability_feedback (
id integer NOT NULL,
created_at timestamp with time zone NOT NULL,
@@ -17789,6 +17835,8 @@ ALTER TABLE ONLY bulk_import_configurations ALTER COLUMN id SET DEFAULT nextval(
ALTER TABLE ONLY bulk_import_entities ALTER COLUMN id SET DEFAULT nextval('bulk_import_entities_id_seq'::regclass);
+ALTER TABLE ONLY bulk_import_failures ALTER COLUMN id SET DEFAULT nextval('bulk_import_failures_id_seq'::regclass);
+
ALTER TABLE ONLY bulk_import_trackers ALTER COLUMN id SET DEFAULT nextval('bulk_import_trackers_id_seq'::regclass);
ALTER TABLE ONLY bulk_imports ALTER COLUMN id SET DEFAULT nextval('bulk_imports_id_seq'::regclass);
@@ -18429,6 +18477,8 @@ ALTER TABLE ONLY vulnerabilities ALTER COLUMN id SET DEFAULT nextval('vulnerabil
ALTER TABLE ONLY vulnerability_exports ALTER COLUMN id SET DEFAULT nextval('vulnerability_exports_id_seq'::regclass);
+ALTER TABLE ONLY vulnerability_external_issue_links ALTER COLUMN id SET DEFAULT nextval('vulnerability_external_issue_links_id_seq'::regclass);
+
ALTER TABLE ONLY vulnerability_feedback ALTER COLUMN id SET DEFAULT nextval('vulnerability_feedback_id_seq'::regclass);
ALTER TABLE ONLY vulnerability_finding_links ALTER COLUMN id SET DEFAULT nextval('vulnerability_finding_links_id_seq'::regclass);
@@ -18815,6 +18865,9 @@ ALTER TABLE ONLY bulk_import_configurations
ALTER TABLE ONLY bulk_import_entities
ADD CONSTRAINT bulk_import_entities_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY bulk_import_failures
+ ADD CONSTRAINT bulk_import_failures_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY bulk_import_trackers
ADD CONSTRAINT bulk_import_trackers_pkey PRIMARY KEY (id);
@@ -19898,6 +19951,9 @@ ALTER TABLE ONLY vulnerabilities
ALTER TABLE ONLY vulnerability_exports
ADD CONSTRAINT vulnerability_exports_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY vulnerability_external_issue_links
+ ADD CONSTRAINT vulnerability_external_issue_links_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY vulnerability_feedback
ADD CONSTRAINT vulnerability_feedback_pkey PRIMARY KEY (id);
@@ -20230,6 +20286,10 @@ CREATE INDEX idx_security_scans_on_scan_type ON security_scans USING btree (scan
CREATE UNIQUE INDEX idx_serverless_domain_cluster_on_clusters_applications_knative ON serverless_domain_cluster USING btree (clusters_applications_knative_id);
+CREATE UNIQUE INDEX idx_vulnerability_ext_issue_links_on_vulne_id_and_ext_issue ON vulnerability_external_issue_links USING btree (vulnerability_id, external_type, external_project_key, external_issue_key);
+
+CREATE UNIQUE INDEX idx_vulnerability_ext_issue_links_on_vulne_id_and_link_type ON vulnerability_external_issue_links USING btree (vulnerability_id, link_type) WHERE (link_type = 1);
+
CREATE UNIQUE INDEX idx_vulnerability_issue_links_on_vulnerability_id_and_issue_id ON vulnerability_issue_links USING btree (vulnerability_id, issue_id);
CREATE UNIQUE INDEX idx_vulnerability_issue_links_on_vulnerability_id_and_link_type ON vulnerability_issue_links USING btree (vulnerability_id, link_type) WHERE (link_type = 2);
@@ -20432,6 +20492,10 @@ CREATE INDEX index_bulk_import_entities_on_parent_id ON bulk_import_entities USI
CREATE INDEX index_bulk_import_entities_on_project_id ON bulk_import_entities USING btree (project_id);
+CREATE INDEX index_bulk_import_failures_on_bulk_import_entity_id ON bulk_import_failures USING btree (bulk_import_entity_id);
+
+CREATE INDEX index_bulk_import_failures_on_correlation_id_value ON bulk_import_failures USING btree (correlation_id_value);
+
CREATE INDEX index_bulk_imports_on_user_id ON bulk_imports USING btree (user_id);
CREATE UNIQUE INDEX index_chat_names_on_service_id_and_team_id_and_chat_id ON chat_names USING btree (service_id, team_id, chat_id);
@@ -22396,6 +22460,10 @@ CREATE INDEX index_vulnerability_exports_on_group_id_not_null ON vulnerability_e
CREATE INDEX index_vulnerability_exports_on_project_id_not_null ON vulnerability_exports USING btree (project_id) WHERE (project_id IS NOT NULL);
+CREATE INDEX index_vulnerability_external_issue_links_on_author_id ON vulnerability_external_issue_links USING btree (author_id);
+
+CREATE INDEX index_vulnerability_external_issue_links_on_vulnerability_id ON vulnerability_external_issue_links USING btree (vulnerability_id);
+
CREATE INDEX index_vulnerability_feedback_on_author_id ON vulnerability_feedback USING btree (author_id);
CREATE INDEX index_vulnerability_feedback_on_comment_author_id ON vulnerability_feedback USING btree (comment_author_id);
@@ -23426,6 +23494,9 @@ ALTER TABLE ONLY emails
ALTER TABLE ONLY clusters
ADD CONSTRAINT fk_f05c5e5a42 FOREIGN KEY (management_project_id) REFERENCES projects(id) ON DELETE SET NULL;
+ALTER TABLE ONLY vulnerability_external_issue_links
+ ADD CONSTRAINT fk_f07bb8233d FOREIGN KEY (vulnerability_id) REFERENCES vulnerabilities(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY epics
ADD CONSTRAINT fk_f081aa4489 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
@@ -23606,6 +23677,9 @@ ALTER TABLE ONLY cluster_providers_aws
ALTER TABLE ONLY grafana_integrations
ADD CONSTRAINT fk_rails_18d0e2b564 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY bulk_import_failures
+ ADD CONSTRAINT fk_rails_1964240b8c FOREIGN KEY (bulk_import_entity_id) REFERENCES bulk_import_entities(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY group_wiki_repositories
ADD CONSTRAINT fk_rails_19755e374b FOREIGN KEY (shard_id) REFERENCES shards(id) ON DELETE RESTRICT;
@@ -24644,6 +24718,9 @@ ALTER TABLE ONLY vulnerability_occurrence_identifiers
ALTER TABLE ONLY serverless_domain_cluster
ADD CONSTRAINT fk_rails_e59e868733 FOREIGN KEY (clusters_applications_knative_id) REFERENCES clusters_applications_knative(id) ON DELETE CASCADE;
+ALTER TABLE ONLY vulnerability_external_issue_links
+ ADD CONSTRAINT fk_rails_e5ba7f7b13 FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE SET NULL;
+
ALTER TABLE ONLY approval_merge_request_rule_sources
ADD CONSTRAINT fk_rails_e605a04f76 FOREIGN KEY (approval_merge_request_rule_id) REFERENCES approval_merge_request_rules(id) ON DELETE CASCADE;