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-04-23 03:09:41 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-23 03:09:41 +0300
commitb158645575a569bd46de15b42355940501902166 (patch)
treeef7ab6549bf28779cf01cbfd84eab23b757a1592 /db
parent22e60f1c61443a7efd8a2334f61556d19d6630be (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20200414112444_add_group_id_to_vulnerability_exports.rb10
-rw-r--r--db/migrate/20200414114611_add_group_id_index_and_fk_to_vulnerability_exports.rb20
-rw-r--r--db/migrate/20200414115801_change_project_index_on_vulnerability_exports.rb21
-rw-r--r--db/migrate/20200417044453_create_alert_management_alerts.rb44
-rw-r--r--db/migrate/20200421233150_add_foreign_keys_for_alert_management_alerts.rb19
-rw-r--r--db/post_migrate/20200401091051_remove_reference_columns_from_resource_milestone_events.rb11
-rw-r--r--db/structure.sql72
7 files changed, 191 insertions, 6 deletions
diff --git a/db/migrate/20200414112444_add_group_id_to_vulnerability_exports.rb b/db/migrate/20200414112444_add_group_id_to_vulnerability_exports.rb
new file mode 100644
index 00000000000..fad63d53a81
--- /dev/null
+++ b/db/migrate/20200414112444_add_group_id_to_vulnerability_exports.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class AddGroupIdToVulnerabilityExports < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :vulnerability_exports, :group_id, :integer
+ change_column_null :vulnerability_exports, :project_id, true
+ end
+end
diff --git a/db/migrate/20200414114611_add_group_id_index_and_fk_to_vulnerability_exports.rb b/db/migrate/20200414114611_add_group_id_index_and_fk_to_vulnerability_exports.rb
new file mode 100644
index 00000000000..a3e60b87857
--- /dev/null
+++ b/db/migrate/20200414114611_add_group_id_index_and_fk_to_vulnerability_exports.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddGroupIdIndexAndFkToVulnerabilityExports < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ GROUP_ID_INDEX_NAME = 'index_vulnerability_exports_on_group_id_not_null'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(:vulnerability_exports, :group_id, where: 'group_id IS NOT NULL', name: GROUP_ID_INDEX_NAME)
+ add_concurrent_foreign_key(:vulnerability_exports, :namespaces, column: :group_id)
+ end
+
+ def down
+ remove_foreign_key(:vulnerability_exports, column: :group_id)
+ remove_concurrent_index_by_name(:vulnerability_exports, GROUP_ID_INDEX_NAME)
+ end
+end
diff --git a/db/migrate/20200414115801_change_project_index_on_vulnerability_exports.rb b/db/migrate/20200414115801_change_project_index_on_vulnerability_exports.rb
new file mode 100644
index 00000000000..e669faa7fca
--- /dev/null
+++ b/db/migrate/20200414115801_change_project_index_on_vulnerability_exports.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class ChangeProjectIndexOnVulnerabilityExports < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ OLD_INDEX_NAME = 'index_vulnerability_exports_on_project_id_and_id'
+ NEW_INDEX_NAME = 'index_vulnerability_exports_on_project_id_not_null'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(:vulnerability_exports, :project_id, where: 'project_id IS NOT NULL', name: NEW_INDEX_NAME)
+ remove_concurrent_index_by_name(:vulnerability_exports, OLD_INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index(:vulnerability_exports, [:project_id, :id], unique: true, name: OLD_INDEX_NAME)
+ remove_concurrent_index_by_name(:vulnerability_exports, NEW_INDEX_NAME)
+ end
+end
diff --git a/db/migrate/20200417044453_create_alert_management_alerts.rb b/db/migrate/20200417044453_create_alert_management_alerts.rb
new file mode 100644
index 00000000000..6221eeeb24b
--- /dev/null
+++ b/db/migrate/20200417044453_create_alert_management_alerts.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+class CreateAlertManagementAlerts < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ unless table_exists?(:alert_management_alerts)
+ create_table :alert_management_alerts do |t|
+ t.timestamps_with_timezone
+ t.datetime_with_timezone :started_at, null: false
+ t.datetime_with_timezone :ended_at
+ t.integer :events, default: 1, null: false
+ t.integer :iid, null: false
+ t.integer :severity, default: 0, null: false, limit: 2
+ t.integer :status, default: 0, null: false, limit: 2
+ t.binary :fingerprint
+ t.bigint :issue_id, index: true
+ t.bigint :project_id, null: false
+ t.text :title, null: false
+ t.text :description
+ t.text :service
+ t.text :monitoring_tool
+ t.text :hosts, array: true, null: false, default: [] # rubocop:disable Migration/AddLimitToTextColumns
+ t.jsonb :payload, null: false, default: {}
+
+ t.index %w(project_id iid), name: 'index_alert_management_alerts_on_project_id_and_iid', unique: true, using: :btree
+ t.index %w(project_id fingerprint), name: 'index_alert_management_alerts_on_project_id_and_fingerprint', unique: true, using: :btree
+ end
+ end
+
+ add_text_limit :alert_management_alerts, :title, 200
+ add_text_limit :alert_management_alerts, :description, 1000
+ add_text_limit :alert_management_alerts, :service, 100
+ add_text_limit :alert_management_alerts, :monitoring_tool, 100
+ end
+
+ def down
+ drop_table :alert_management_alerts
+ end
+end
diff --git a/db/migrate/20200421233150_add_foreign_keys_for_alert_management_alerts.rb b/db/migrate/20200421233150_add_foreign_keys_for_alert_management_alerts.rb
new file mode 100644
index 00000000000..b16bdf9830c
--- /dev/null
+++ b/db/migrate/20200421233150_add_foreign_keys_for_alert_management_alerts.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddForeignKeysForAlertManagementAlerts < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :alert_management_alerts, :projects, column: :project_id, on_delete: :cascade
+ add_concurrent_foreign_key :alert_management_alerts, :issues, column: :issue_id, on_delete: :nullify
+ end
+
+ def down
+ remove_foreign_key_if_exists :alert_management_alerts, column: :project_id
+ remove_foreign_key_if_exists :alert_management_alerts, column: :issue_id
+ end
+end
diff --git a/db/post_migrate/20200401091051_remove_reference_columns_from_resource_milestone_events.rb b/db/post_migrate/20200401091051_remove_reference_columns_from_resource_milestone_events.rb
new file mode 100644
index 00000000000..639ab93cf18
--- /dev/null
+++ b/db/post_migrate/20200401091051_remove_reference_columns_from_resource_milestone_events.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class RemoveReferenceColumnsFromResourceMilestoneEvents < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ remove_column :resource_milestone_events, :reference, :text
+ remove_column :resource_milestone_events, :reference_html, :text
+ remove_column :resource_milestone_events, :cached_markdown_version, :integer
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index faf61a6986a..759465c6845 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -24,6 +24,40 @@ CREATE SEQUENCE public.abuse_reports_id_seq
ALTER SEQUENCE public.abuse_reports_id_seq OWNED BY public.abuse_reports.id;
+CREATE TABLE public.alert_management_alerts (
+ id bigint NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ started_at timestamp with time zone NOT NULL,
+ ended_at timestamp with time zone,
+ events integer DEFAULT 1 NOT NULL,
+ iid integer NOT NULL,
+ severity smallint DEFAULT 0 NOT NULL,
+ status smallint DEFAULT 0 NOT NULL,
+ fingerprint bytea,
+ issue_id bigint,
+ project_id bigint NOT NULL,
+ title text NOT NULL,
+ description text,
+ service text,
+ monitoring_tool text,
+ hosts text[] DEFAULT '{}'::text[] NOT NULL,
+ payload jsonb DEFAULT '{}'::jsonb NOT NULL,
+ CONSTRAINT check_2df3e2fdc1 CHECK ((char_length(monitoring_tool) <= 100)),
+ CONSTRAINT check_5e9e57cadb CHECK ((char_length(description) <= 1000)),
+ CONSTRAINT check_bac14dddde CHECK ((char_length(service) <= 100)),
+ CONSTRAINT check_d1d1c2d14c CHECK ((char_length(title) <= 200))
+);
+
+CREATE SEQUENCE public.alert_management_alerts_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE public.alert_management_alerts_id_seq OWNED BY public.alert_management_alerts.id;
+
CREATE TABLE public.alerts_service_data (
id bigint NOT NULL,
service_id integer NOT NULL,
@@ -5597,9 +5631,6 @@ CREATE TABLE public.resource_milestone_events (
milestone_id bigint,
action smallint NOT NULL,
state smallint NOT NULL,
- cached_markdown_version integer,
- reference text,
- reference_html text,
created_at timestamp with time zone NOT NULL
);
@@ -6661,10 +6692,11 @@ CREATE TABLE public.vulnerability_exports (
finished_at timestamp with time zone,
status character varying(255) NOT NULL,
file character varying(255),
- project_id bigint NOT NULL,
+ project_id bigint,
author_id bigint NOT NULL,
file_store integer,
- format smallint DEFAULT 0 NOT NULL
+ format smallint DEFAULT 0 NOT NULL,
+ group_id integer
);
CREATE SEQUENCE public.vulnerability_exports_id_seq
@@ -7014,6 +7046,8 @@ ALTER SEQUENCE public.zoom_meetings_id_seq OWNED BY public.zoom_meetings.id;
ALTER TABLE ONLY public.abuse_reports ALTER COLUMN id SET DEFAULT nextval('public.abuse_reports_id_seq'::regclass);
+ALTER TABLE ONLY public.alert_management_alerts ALTER COLUMN id SET DEFAULT nextval('public.alert_management_alerts_id_seq'::regclass);
+
ALTER TABLE ONLY public.alerts_service_data ALTER COLUMN id SET DEFAULT nextval('public.alerts_service_data_id_seq'::regclass);
ALTER TABLE ONLY public.allowed_email_domains ALTER COLUMN id SET DEFAULT nextval('public.allowed_email_domains_id_seq'::regclass);
@@ -7623,6 +7657,9 @@ ALTER TABLE ONLY public.zoom_meetings ALTER COLUMN id SET DEFAULT nextval('publi
ALTER TABLE ONLY public.abuse_reports
ADD CONSTRAINT abuse_reports_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY public.alert_management_alerts
+ ADD CONSTRAINT alert_management_alerts_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY public.alerts_service_data
ADD CONSTRAINT alerts_service_data_pkey PRIMARY KEY (id);
@@ -8686,6 +8723,12 @@ CREATE UNIQUE INDEX idx_vulnerability_issue_links_on_vulnerability_id_and_link_t
CREATE INDEX index_abuse_reports_on_user_id ON public.abuse_reports USING btree (user_id);
+CREATE INDEX index_alert_management_alerts_on_issue_id ON public.alert_management_alerts USING btree (issue_id);
+
+CREATE UNIQUE INDEX index_alert_management_alerts_on_project_id_and_fingerprint ON public.alert_management_alerts USING btree (project_id, fingerprint);
+
+CREATE UNIQUE INDEX index_alert_management_alerts_on_project_id_and_iid ON public.alert_management_alerts USING btree (project_id, iid);
+
CREATE INDEX index_alerts_service_data_on_service_id ON public.alerts_service_data USING btree (service_id);
CREATE INDEX index_allowed_email_domains_on_group_id ON public.allowed_email_domains USING btree (group_id);
@@ -10442,7 +10485,9 @@ CREATE INDEX index_vulnerabilities_on_updated_by_id ON public.vulnerabilities US
CREATE INDEX index_vulnerability_exports_on_author_id ON public.vulnerability_exports USING btree (author_id);
-CREATE UNIQUE INDEX index_vulnerability_exports_on_project_id_and_id ON public.vulnerability_exports USING btree (project_id, id);
+CREATE INDEX index_vulnerability_exports_on_group_id_not_null ON public.vulnerability_exports USING btree (group_id) WHERE (group_id IS NOT NULL);
+
+CREATE INDEX index_vulnerability_exports_on_project_id_not_null ON public.vulnerability_exports USING btree (project_id) WHERE (project_id IS NOT NULL);
CREATE INDEX index_vulnerability_feedback_on_author_id ON public.vulnerability_feedback USING btree (author_id);
@@ -10639,6 +10684,9 @@ ALTER TABLE ONLY public.geo_container_repository_updated_events
ALTER TABLE ONLY public.users_star_projects
ADD CONSTRAINT fk_22cd27ddfc FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
+ALTER TABLE ONLY public.alert_management_alerts
+ ADD CONSTRAINT fk_2358b75436 FOREIGN KEY (issue_id) REFERENCES public.issues(id) ON DELETE SET NULL;
+
ALTER TABLE ONLY public.ci_stages
ADD CONSTRAINT fk_2360681d1d FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
@@ -10894,6 +10942,9 @@ ALTER TABLE ONLY public.issues
ALTER TABLE ONLY public.epics
ADD CONSTRAINT fk_9d480c64b2 FOREIGN KEY (start_date_sourcing_epic_id) REFERENCES public.epics(id) ON DELETE SET NULL;
+ALTER TABLE ONLY public.alert_management_alerts
+ ADD CONSTRAINT fk_9e49e5c2b7 FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY public.ci_pipeline_schedules
ADD CONSTRAINT fk_9ea99f58d2 FOREIGN KEY (owner_id) REFERENCES public.users(id) ON DELETE SET NULL;
@@ -10975,6 +11026,9 @@ ALTER TABLE ONLY public.design_management_versions
ALTER TABLE ONLY public.geo_event_log
ADD CONSTRAINT fk_c1f241c70d FOREIGN KEY (upload_deleted_event_id) REFERENCES public.geo_upload_deleted_events(id) ON DELETE CASCADE;
+ALTER TABLE ONLY public.vulnerability_exports
+ ADD CONSTRAINT fk_c3d3cb5d0f FOREIGN KEY (group_id) REFERENCES public.namespaces(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY public.geo_event_log
ADD CONSTRAINT fk_c4b1c1f66e FOREIGN KEY (repository_deleted_event_id) REFERENCES public.geo_repository_deleted_events(id) ON DELETE CASCADE;
@@ -13212,6 +13266,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200331132103
20200331195952
20200331220930
+20200401091051
20200401095430
20200401211005
20200402123926
@@ -13257,6 +13312,9 @@ COPY "schema_migrations" (version) FROM STDIN;
20200411125656
20200413072059
20200413230056
+20200414112444
+20200414114611
+20200414115801
20200414144547
20200415153154
20200415160722
@@ -13266,5 +13324,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200416111111
20200416120128
20200416120354
+20200417044453
+20200421233150
\.