diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-19 00:09:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-19 00:09:17 +0300 |
commit | a407a618ae21dce15c85ae15c465a531811a69b9 (patch) | |
tree | 698b42a38f42ae333c58e48f9f954d23035c5f64 /db/init_structure.sql | |
parent | 9f2bc6fc4c27d0703260352c79463fbc62555ac8 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db/init_structure.sql')
-rw-r--r-- | db/init_structure.sql | 1396 |
1 files changed, 820 insertions, 576 deletions
diff --git a/db/init_structure.sql b/db/init_structure.sql index aee0f767996..63961f05c6b 100644 --- a/db/init_structure.sql +++ b/db/init_structure.sql @@ -45,23 +45,45 @@ RETURN NULL; END $$; -CREATE FUNCTION insert_projects_sync_event() RETURNS trigger +CREATE FUNCTION insert_or_update_vulnerability_reads() RETURNS trigger LANGUAGE plpgsql AS $$ +DECLARE + severity smallint; + state smallint; + report_type smallint; + resolved_on_default_branch boolean; BEGIN -INSERT INTO projects_sync_events (project_id) -VALUES(COALESCE(NEW.id, OLD.id)); -RETURN NULL; - + IF (NEW.vulnerability_id IS NULL AND (TG_OP = 'INSERT' OR TG_OP = 'UPDATE')) THEN + RETURN NULL; + END IF; + + IF (TG_OP = 'UPDATE' AND OLD.vulnerability_id IS NOT NULL AND NEW.vulnerability_id IS NOT NULL) THEN + RETURN NULL; + END IF; + + SELECT + vulnerabilities.severity, vulnerabilities.state, vulnerabilities.report_type, vulnerabilities.resolved_on_default_branch + INTO + severity, state, report_type, resolved_on_default_branch + FROM + vulnerabilities + WHERE + vulnerabilities.id = NEW.vulnerability_id; + + INSERT INTO vulnerability_reads (vulnerability_id, project_id, scanner_id, report_type, severity, state, resolved_on_default_branch, uuid, location_image, cluster_agent_id) + VALUES (NEW.vulnerability_id, NEW.project_id, NEW.scanner_id, report_type, severity, state, resolved_on_default_branch, NEW.uuid::uuid, NEW.location->>'image', NEW.location->'kubernetes_resource'->>'agent_id') + ON CONFLICT(vulnerability_id) DO NOTHING; + RETURN NULL; END $$; -CREATE FUNCTION integrations_set_type_new() RETURNS trigger +CREATE FUNCTION insert_projects_sync_event() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN -UPDATE integrations SET type_new = regexp_replace(NEW.type, '\A(.+)Service\Z', 'Integrations::\1') -WHERE integrations.id = NEW.id; +INSERT INTO projects_sync_events (project_id) +VALUES(COALESCE(NEW.id, OLD.id)); RETURN NULL; END @@ -107,6 +129,83 @@ RETURN NULL; END $$; +CREATE FUNCTION set_has_issues_on_vulnerability_reads() RETURNS trigger + LANGUAGE plpgsql + AS $$ +BEGIN +UPDATE + vulnerability_reads +SET + has_issues = true +WHERE + vulnerability_id = NEW.vulnerability_id AND has_issues IS FALSE; +RETURN NULL; + +END +$$; + +CREATE FUNCTION unset_has_issues_on_vulnerability_reads() RETURNS trigger + LANGUAGE plpgsql + AS $$ +DECLARE + has_issue_links integer; +BEGIN + PERFORM 1 + FROM + vulnerability_reads + WHERE + vulnerability_id = OLD.vulnerability_id + FOR UPDATE; + + SELECT 1 INTO has_issue_links FROM vulnerability_issue_links WHERE vulnerability_id = OLD.vulnerability_id LIMIT 1; + + IF (has_issue_links = 1) THEN + RETURN NULL; + END IF; + + UPDATE + vulnerability_reads + SET + has_issues = false + WHERE + vulnerability_id = OLD.vulnerability_id; + + RETURN NULL; +END +$$; + +CREATE FUNCTION update_location_from_vulnerability_occurrences() RETURNS trigger + LANGUAGE plpgsql + AS $$ +BEGIN +UPDATE + vulnerability_reads +SET + location_image = NEW.location->>'image', + cluster_agent_id = NEW.location->'kubernetes_resource'->>'agent_id' +WHERE + vulnerability_id = NEW.vulnerability_id; +RETURN NULL; + +END +$$; + +CREATE FUNCTION update_vulnerability_reads_from_vulnerability() RETURNS trigger + LANGUAGE plpgsql + AS $$ +BEGIN +UPDATE + vulnerability_reads +SET + severity = NEW.severity, + state = NEW.state, + resolved_on_default_branch = NEW.resolved_on_default_branch +WHERE vulnerability_id = NEW.id; +RETURN NULL; + +END +$$; + CREATE TABLE audit_events ( id bigint NOT NULL, author_id integer NOT NULL, @@ -392,7 +491,7 @@ CREATE TABLE gitlab_partitions_dynamic.batched_background_migration_job_transiti CONSTRAINT check_50e580811a CHECK ((char_length(exception_message) <= 1000)), CONSTRAINT check_76e202c37a CHECK ((char_length(exception_class) <= 100)) ); -ALTER TABLE ONLY batched_background_migration_job_transition_logs ATTACH PARTITION gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_000000 FOR VALUES FROM (MINVALUE) TO ('2023-02-28 18:00:00-06'); +ALTER TABLE ONLY batched_background_migration_job_transition_logs ATTACH PARTITION gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_000000 FOR VALUES FROM (MINVALUE) TO ('2023-03-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202303 ( id bigint DEFAULT nextval('batched_background_migration_job_transition_logs_id_seq'::regclass) NOT NULL, @@ -406,7 +505,7 @@ CREATE TABLE gitlab_partitions_dynamic.batched_background_migration_job_transiti CONSTRAINT check_50e580811a CHECK ((char_length(exception_message) <= 1000)), CONSTRAINT check_76e202c37a CHECK ((char_length(exception_class) <= 100)) ); -ALTER TABLE ONLY batched_background_migration_job_transition_logs ATTACH PARTITION gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202303 FOR VALUES FROM ('2023-02-28 18:00:00-06') TO ('2023-03-31 19:00:00-05'); +ALTER TABLE ONLY batched_background_migration_job_transition_logs ATTACH PARTITION gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202303 FOR VALUES FROM ('2023-03-01 00:00:00+00') TO ('2023-04-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202304 ( id bigint DEFAULT nextval('batched_background_migration_job_transition_logs_id_seq'::regclass) NOT NULL, @@ -420,7 +519,7 @@ CREATE TABLE gitlab_partitions_dynamic.batched_background_migration_job_transiti CONSTRAINT check_50e580811a CHECK ((char_length(exception_message) <= 1000)), CONSTRAINT check_76e202c37a CHECK ((char_length(exception_class) <= 100)) ); -ALTER TABLE ONLY batched_background_migration_job_transition_logs ATTACH PARTITION gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202304 FOR VALUES FROM ('2023-03-31 19:00:00-05') TO ('2023-04-30 19:00:00-05'); +ALTER TABLE ONLY batched_background_migration_job_transition_logs ATTACH PARTITION gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202304 FOR VALUES FROM ('2023-04-01 00:00:00+00') TO ('2023-05-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202305 ( id bigint DEFAULT nextval('batched_background_migration_job_transition_logs_id_seq'::regclass) NOT NULL, @@ -434,7 +533,7 @@ CREATE TABLE gitlab_partitions_dynamic.batched_background_migration_job_transiti CONSTRAINT check_50e580811a CHECK ((char_length(exception_message) <= 1000)), CONSTRAINT check_76e202c37a CHECK ((char_length(exception_class) <= 100)) ); -ALTER TABLE ONLY batched_background_migration_job_transition_logs ATTACH PARTITION gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202305 FOR VALUES FROM ('2023-04-30 19:00:00-05') TO ('2023-05-31 19:00:00-05'); +ALTER TABLE ONLY batched_background_migration_job_transition_logs ATTACH PARTITION gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202305 FOR VALUES FROM ('2023-05-01 00:00:00+00') TO ('2023-06-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202306 ( id bigint DEFAULT nextval('batched_background_migration_job_transition_logs_id_seq'::regclass) NOT NULL, @@ -448,7 +547,7 @@ CREATE TABLE gitlab_partitions_dynamic.batched_background_migration_job_transiti CONSTRAINT check_50e580811a CHECK ((char_length(exception_message) <= 1000)), CONSTRAINT check_76e202c37a CHECK ((char_length(exception_class) <= 100)) ); -ALTER TABLE ONLY batched_background_migration_job_transition_logs ATTACH PARTITION gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202306 FOR VALUES FROM ('2023-05-31 19:00:00-05') TO ('2023-06-30 19:00:00-05'); +ALTER TABLE ONLY batched_background_migration_job_transition_logs ATTACH PARTITION gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202306 FOR VALUES FROM ('2023-06-01 00:00:00+00') TO ('2023-07-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202307 ( id bigint DEFAULT nextval('batched_background_migration_job_transition_logs_id_seq'::regclass) NOT NULL, @@ -462,7 +561,7 @@ CREATE TABLE gitlab_partitions_dynamic.batched_background_migration_job_transiti CONSTRAINT check_50e580811a CHECK ((char_length(exception_message) <= 1000)), CONSTRAINT check_76e202c37a CHECK ((char_length(exception_class) <= 100)) ); -ALTER TABLE ONLY batched_background_migration_job_transition_logs ATTACH PARTITION gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202307 FOR VALUES FROM ('2023-06-30 19:00:00-05') TO ('2023-07-31 19:00:00-05'); +ALTER TABLE ONLY batched_background_migration_job_transition_logs ATTACH PARTITION gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202307 FOR VALUES FROM ('2023-07-01 00:00:00+00') TO ('2023-08-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202308 ( id bigint DEFAULT nextval('batched_background_migration_job_transition_logs_id_seq'::regclass) NOT NULL, @@ -476,7 +575,7 @@ CREATE TABLE gitlab_partitions_dynamic.batched_background_migration_job_transiti CONSTRAINT check_50e580811a CHECK ((char_length(exception_message) <= 1000)), CONSTRAINT check_76e202c37a CHECK ((char_length(exception_class) <= 100)) ); -ALTER TABLE ONLY batched_background_migration_job_transition_logs ATTACH PARTITION gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202308 FOR VALUES FROM ('2023-07-31 19:00:00-05') TO ('2023-08-31 19:00:00-05'); +ALTER TABLE ONLY batched_background_migration_job_transition_logs ATTACH PARTITION gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202308 FOR VALUES FROM ('2023-08-01 00:00:00+00') TO ('2023-09-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202309 ( id bigint DEFAULT nextval('batched_background_migration_job_transition_logs_id_seq'::regclass) NOT NULL, @@ -490,7 +589,7 @@ CREATE TABLE gitlab_partitions_dynamic.batched_background_migration_job_transiti CONSTRAINT check_50e580811a CHECK ((char_length(exception_message) <= 1000)), CONSTRAINT check_76e202c37a CHECK ((char_length(exception_class) <= 100)) ); -ALTER TABLE ONLY batched_background_migration_job_transition_logs ATTACH PARTITION gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202309 FOR VALUES FROM ('2023-08-31 19:00:00-05') TO ('2023-09-30 19:00:00-05'); +ALTER TABLE ONLY batched_background_migration_job_transition_logs ATTACH PARTITION gitlab_partitions_dynamic.batched_background_migration_job_transition_logs_202309 FOR VALUES FROM ('2023-09-01 00:00:00+00') TO ('2023-10-01 00:00:00+00'); CREATE TABLE incident_management_pending_alert_escalations ( id bigint NOT NULL, @@ -537,7 +636,7 @@ CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_alert_escalat created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -ALTER TABLE ONLY incident_management_pending_alert_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202301 FOR VALUES FROM ('2022-12-31 18:00:00-06') TO ('2023-01-31 18:00:00-06'); +ALTER TABLE ONLY incident_management_pending_alert_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202301 FOR VALUES FROM ('2023-01-01 00:00:00+00') TO ('2023-02-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202302 ( id bigint DEFAULT nextval('incident_management_pending_alert_escalations_id_seq'::regclass) NOT NULL, @@ -547,7 +646,7 @@ CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_alert_escalat created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -ALTER TABLE ONLY incident_management_pending_alert_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202302 FOR VALUES FROM ('2023-01-31 18:00:00-06') TO ('2023-02-28 18:00:00-06'); +ALTER TABLE ONLY incident_management_pending_alert_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202302 FOR VALUES FROM ('2023-02-01 00:00:00+00') TO ('2023-03-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202303 ( id bigint DEFAULT nextval('incident_management_pending_alert_escalations_id_seq'::regclass) NOT NULL, @@ -557,7 +656,7 @@ CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_alert_escalat created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -ALTER TABLE ONLY incident_management_pending_alert_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202303 FOR VALUES FROM ('2023-02-28 18:00:00-06') TO ('2023-03-31 19:00:00-05'); +ALTER TABLE ONLY incident_management_pending_alert_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202303 FOR VALUES FROM ('2023-03-01 00:00:00+00') TO ('2023-04-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202304 ( id bigint DEFAULT nextval('incident_management_pending_alert_escalations_id_seq'::regclass) NOT NULL, @@ -567,7 +666,7 @@ CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_alert_escalat created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -ALTER TABLE ONLY incident_management_pending_alert_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202304 FOR VALUES FROM ('2023-03-31 19:00:00-05') TO ('2023-04-30 19:00:00-05'); +ALTER TABLE ONLY incident_management_pending_alert_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202304 FOR VALUES FROM ('2023-04-01 00:00:00+00') TO ('2023-05-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202305 ( id bigint DEFAULT nextval('incident_management_pending_alert_escalations_id_seq'::regclass) NOT NULL, @@ -577,7 +676,7 @@ CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_alert_escalat created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -ALTER TABLE ONLY incident_management_pending_alert_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202305 FOR VALUES FROM ('2023-04-30 19:00:00-05') TO ('2023-05-31 19:00:00-05'); +ALTER TABLE ONLY incident_management_pending_alert_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202305 FOR VALUES FROM ('2023-05-01 00:00:00+00') TO ('2023-06-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202306 ( id bigint DEFAULT nextval('incident_management_pending_alert_escalations_id_seq'::regclass) NOT NULL, @@ -587,7 +686,7 @@ CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_alert_escalat created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -ALTER TABLE ONLY incident_management_pending_alert_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202306 FOR VALUES FROM ('2023-05-31 19:00:00-05') TO ('2023-06-30 19:00:00-05'); +ALTER TABLE ONLY incident_management_pending_alert_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202306 FOR VALUES FROM ('2023-06-01 00:00:00+00') TO ('2023-07-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202307 ( id bigint DEFAULT nextval('incident_management_pending_alert_escalations_id_seq'::regclass) NOT NULL, @@ -597,7 +696,7 @@ CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_alert_escalat created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -ALTER TABLE ONLY incident_management_pending_alert_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202307 FOR VALUES FROM ('2023-06-30 19:00:00-05') TO ('2023-07-31 19:00:00-05'); +ALTER TABLE ONLY incident_management_pending_alert_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202307 FOR VALUES FROM ('2023-07-01 00:00:00+00') TO ('2023-08-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202308 ( id bigint DEFAULT nextval('incident_management_pending_alert_escalations_id_seq'::regclass) NOT NULL, @@ -607,7 +706,7 @@ CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_alert_escalat created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -ALTER TABLE ONLY incident_management_pending_alert_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202308 FOR VALUES FROM ('2023-07-31 19:00:00-05') TO ('2023-08-31 19:00:00-05'); +ALTER TABLE ONLY incident_management_pending_alert_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202308 FOR VALUES FROM ('2023-08-01 00:00:00+00') TO ('2023-09-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202309 ( id bigint DEFAULT nextval('incident_management_pending_alert_escalations_id_seq'::regclass) NOT NULL, @@ -617,7 +716,7 @@ CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_alert_escalat created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -ALTER TABLE ONLY incident_management_pending_alert_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202309 FOR VALUES FROM ('2023-08-31 19:00:00-05') TO ('2023-09-30 19:00:00-05'); +ALTER TABLE ONLY incident_management_pending_alert_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_alert_escalations_202309 FOR VALUES FROM ('2023-09-01 00:00:00+00') TO ('2023-10-01 00:00:00+00'); CREATE TABLE incident_management_pending_issue_escalations ( id bigint NOT NULL, @@ -664,7 +763,7 @@ CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_issue_escalat created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -ALTER TABLE ONLY incident_management_pending_issue_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202301 FOR VALUES FROM ('2022-12-31 18:00:00-06') TO ('2023-01-31 18:00:00-06'); +ALTER TABLE ONLY incident_management_pending_issue_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202301 FOR VALUES FROM ('2023-01-01 00:00:00+00') TO ('2023-02-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202302 ( id bigint DEFAULT nextval('incident_management_pending_issue_escalations_id_seq'::regclass) NOT NULL, @@ -674,7 +773,7 @@ CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_issue_escalat created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -ALTER TABLE ONLY incident_management_pending_issue_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202302 FOR VALUES FROM ('2023-01-31 18:00:00-06') TO ('2023-02-28 18:00:00-06'); +ALTER TABLE ONLY incident_management_pending_issue_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202302 FOR VALUES FROM ('2023-02-01 00:00:00+00') TO ('2023-03-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202303 ( id bigint DEFAULT nextval('incident_management_pending_issue_escalations_id_seq'::regclass) NOT NULL, @@ -684,7 +783,7 @@ CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_issue_escalat created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -ALTER TABLE ONLY incident_management_pending_issue_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202303 FOR VALUES FROM ('2023-02-28 18:00:00-06') TO ('2023-03-31 19:00:00-05'); +ALTER TABLE ONLY incident_management_pending_issue_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202303 FOR VALUES FROM ('2023-03-01 00:00:00+00') TO ('2023-04-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202304 ( id bigint DEFAULT nextval('incident_management_pending_issue_escalations_id_seq'::regclass) NOT NULL, @@ -694,7 +793,7 @@ CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_issue_escalat created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -ALTER TABLE ONLY incident_management_pending_issue_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202304 FOR VALUES FROM ('2023-03-31 19:00:00-05') TO ('2023-04-30 19:00:00-05'); +ALTER TABLE ONLY incident_management_pending_issue_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202304 FOR VALUES FROM ('2023-04-01 00:00:00+00') TO ('2023-05-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202305 ( id bigint DEFAULT nextval('incident_management_pending_issue_escalations_id_seq'::regclass) NOT NULL, @@ -704,7 +803,7 @@ CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_issue_escalat created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -ALTER TABLE ONLY incident_management_pending_issue_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202305 FOR VALUES FROM ('2023-04-30 19:00:00-05') TO ('2023-05-31 19:00:00-05'); +ALTER TABLE ONLY incident_management_pending_issue_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202305 FOR VALUES FROM ('2023-05-01 00:00:00+00') TO ('2023-06-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202306 ( id bigint DEFAULT nextval('incident_management_pending_issue_escalations_id_seq'::regclass) NOT NULL, @@ -714,7 +813,7 @@ CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_issue_escalat created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -ALTER TABLE ONLY incident_management_pending_issue_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202306 FOR VALUES FROM ('2023-05-31 19:00:00-05') TO ('2023-06-30 19:00:00-05'); +ALTER TABLE ONLY incident_management_pending_issue_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202306 FOR VALUES FROM ('2023-06-01 00:00:00+00') TO ('2023-07-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202307 ( id bigint DEFAULT nextval('incident_management_pending_issue_escalations_id_seq'::regclass) NOT NULL, @@ -724,7 +823,7 @@ CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_issue_escalat created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -ALTER TABLE ONLY incident_management_pending_issue_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202307 FOR VALUES FROM ('2023-06-30 19:00:00-05') TO ('2023-07-31 19:00:00-05'); +ALTER TABLE ONLY incident_management_pending_issue_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202307 FOR VALUES FROM ('2023-07-01 00:00:00+00') TO ('2023-08-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202308 ( id bigint DEFAULT nextval('incident_management_pending_issue_escalations_id_seq'::regclass) NOT NULL, @@ -734,7 +833,7 @@ CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_issue_escalat created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -ALTER TABLE ONLY incident_management_pending_issue_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202308 FOR VALUES FROM ('2023-07-31 19:00:00-05') TO ('2023-08-31 19:00:00-05'); +ALTER TABLE ONLY incident_management_pending_issue_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202308 FOR VALUES FROM ('2023-08-01 00:00:00+00') TO ('2023-09-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202309 ( id bigint DEFAULT nextval('incident_management_pending_issue_escalations_id_seq'::regclass) NOT NULL, @@ -744,7 +843,42 @@ CREATE TABLE gitlab_partitions_dynamic.incident_management_pending_issue_escalat created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL ); -ALTER TABLE ONLY incident_management_pending_issue_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202309 FOR VALUES FROM ('2023-08-31 19:00:00-05') TO ('2023-09-30 19:00:00-05'); +ALTER TABLE ONLY incident_management_pending_issue_escalations ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202309 FOR VALUES FROM ('2023-09-01 00:00:00+00') TO ('2023-10-01 00:00:00+00'); + +CREATE TABLE loose_foreign_keys_deleted_records ( + id bigint NOT NULL, + partition bigint DEFAULT 1 NOT NULL, + primary_key_value bigint NOT NULL, + status smallint DEFAULT 1 NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + fully_qualified_table_name text NOT NULL, + consume_after timestamp with time zone DEFAULT now(), + cleanup_attempts smallint DEFAULT 0, + CONSTRAINT check_1a541f3235 CHECK ((char_length(fully_qualified_table_name) <= 150)) +) +PARTITION BY LIST (partition); + +CREATE SEQUENCE loose_foreign_keys_deleted_records_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE loose_foreign_keys_deleted_records_id_seq OWNED BY loose_foreign_keys_deleted_records.id; + +CREATE TABLE gitlab_partitions_dynamic.loose_foreign_keys_deleted_records_1 ( + id bigint DEFAULT nextval('loose_foreign_keys_deleted_records_id_seq'::regclass) NOT NULL, + partition bigint DEFAULT 1 NOT NULL, + primary_key_value bigint NOT NULL, + status smallint DEFAULT 1 NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + fully_qualified_table_name text NOT NULL, + consume_after timestamp with time zone DEFAULT now(), + cleanup_attempts smallint DEFAULT 0, + CONSTRAINT check_1a541f3235 CHECK ((char_length(fully_qualified_table_name) <= 150)) +); +ALTER TABLE ONLY loose_foreign_keys_deleted_records ATTACH PARTITION gitlab_partitions_dynamic.loose_foreign_keys_deleted_records_1 FOR VALUES IN ('1'); CREATE TABLE verification_codes ( created_at timestamp with time zone DEFAULT now() NOT NULL, @@ -753,7 +887,7 @@ CREATE TABLE verification_codes ( phone text NOT NULL, CONSTRAINT check_9b84e6aaff CHECK ((char_length(code) <= 8)), CONSTRAINT check_ccc542256b CHECK ((char_length(visitor_id_code) <= 64)), - CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 32)) + CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 50)) ) PARTITION BY RANGE (created_at); @@ -766,9 +900,9 @@ CREATE TABLE gitlab_partitions_dynamic.verification_codes_000000 ( phone text NOT NULL, CONSTRAINT check_9b84e6aaff CHECK ((char_length(code) <= 8)), CONSTRAINT check_ccc542256b CHECK ((char_length(visitor_id_code) <= 64)), - CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 32)) + CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 50)) ); -ALTER TABLE ONLY verification_codes ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_000000 FOR VALUES FROM (MINVALUE) TO ('2023-01-31 18:00:00-06'); +ALTER TABLE ONLY verification_codes ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_000000 FOR VALUES FROM (MINVALUE) TO ('2023-02-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.verification_codes_202302 ( created_at timestamp with time zone DEFAULT now() NOT NULL, @@ -777,9 +911,9 @@ CREATE TABLE gitlab_partitions_dynamic.verification_codes_202302 ( phone text NOT NULL, CONSTRAINT check_9b84e6aaff CHECK ((char_length(code) <= 8)), CONSTRAINT check_ccc542256b CHECK ((char_length(visitor_id_code) <= 64)), - CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 32)) + CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 50)) ); -ALTER TABLE ONLY verification_codes ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_202302 FOR VALUES FROM ('2023-01-31 18:00:00-06') TO ('2023-02-28 18:00:00-06'); +ALTER TABLE ONLY verification_codes ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_202302 FOR VALUES FROM ('2023-02-01 00:00:00+00') TO ('2023-03-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.verification_codes_202303 ( created_at timestamp with time zone DEFAULT now() NOT NULL, @@ -788,9 +922,9 @@ CREATE TABLE gitlab_partitions_dynamic.verification_codes_202303 ( phone text NOT NULL, CONSTRAINT check_9b84e6aaff CHECK ((char_length(code) <= 8)), CONSTRAINT check_ccc542256b CHECK ((char_length(visitor_id_code) <= 64)), - CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 32)) + CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 50)) ); -ALTER TABLE ONLY verification_codes ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_202303 FOR VALUES FROM ('2023-02-28 18:00:00-06') TO ('2023-03-31 19:00:00-05'); +ALTER TABLE ONLY verification_codes ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_202303 FOR VALUES FROM ('2023-03-01 00:00:00+00') TO ('2023-04-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.verification_codes_202304 ( created_at timestamp with time zone DEFAULT now() NOT NULL, @@ -799,9 +933,9 @@ CREATE TABLE gitlab_partitions_dynamic.verification_codes_202304 ( phone text NOT NULL, CONSTRAINT check_9b84e6aaff CHECK ((char_length(code) <= 8)), CONSTRAINT check_ccc542256b CHECK ((char_length(visitor_id_code) <= 64)), - CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 32)) + CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 50)) ); -ALTER TABLE ONLY verification_codes ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_202304 FOR VALUES FROM ('2023-03-31 19:00:00-05') TO ('2023-04-30 19:00:00-05'); +ALTER TABLE ONLY verification_codes ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_202304 FOR VALUES FROM ('2023-04-01 00:00:00+00') TO ('2023-05-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.verification_codes_202305 ( created_at timestamp with time zone DEFAULT now() NOT NULL, @@ -810,9 +944,9 @@ CREATE TABLE gitlab_partitions_dynamic.verification_codes_202305 ( phone text NOT NULL, CONSTRAINT check_9b84e6aaff CHECK ((char_length(code) <= 8)), CONSTRAINT check_ccc542256b CHECK ((char_length(visitor_id_code) <= 64)), - CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 32)) + CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 50)) ); -ALTER TABLE ONLY verification_codes ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_202305 FOR VALUES FROM ('2023-04-30 19:00:00-05') TO ('2023-05-31 19:00:00-05'); +ALTER TABLE ONLY verification_codes ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_202305 FOR VALUES FROM ('2023-05-01 00:00:00+00') TO ('2023-06-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.verification_codes_202306 ( created_at timestamp with time zone DEFAULT now() NOT NULL, @@ -821,9 +955,9 @@ CREATE TABLE gitlab_partitions_dynamic.verification_codes_202306 ( phone text NOT NULL, CONSTRAINT check_9b84e6aaff CHECK ((char_length(code) <= 8)), CONSTRAINT check_ccc542256b CHECK ((char_length(visitor_id_code) <= 64)), - CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 32)) + CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 50)) ); -ALTER TABLE ONLY verification_codes ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_202306 FOR VALUES FROM ('2023-05-31 19:00:00-05') TO ('2023-06-30 19:00:00-05'); +ALTER TABLE ONLY verification_codes ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_202306 FOR VALUES FROM ('2023-06-01 00:00:00+00') TO ('2023-07-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.verification_codes_202307 ( created_at timestamp with time zone DEFAULT now() NOT NULL, @@ -832,9 +966,9 @@ CREATE TABLE gitlab_partitions_dynamic.verification_codes_202307 ( phone text NOT NULL, CONSTRAINT check_9b84e6aaff CHECK ((char_length(code) <= 8)), CONSTRAINT check_ccc542256b CHECK ((char_length(visitor_id_code) <= 64)), - CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 32)) + CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 50)) ); -ALTER TABLE ONLY verification_codes ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_202307 FOR VALUES FROM ('2023-06-30 19:00:00-05') TO ('2023-07-31 19:00:00-05'); +ALTER TABLE ONLY verification_codes ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_202307 FOR VALUES FROM ('2023-07-01 00:00:00+00') TO ('2023-08-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.verification_codes_202308 ( created_at timestamp with time zone DEFAULT now() NOT NULL, @@ -843,9 +977,9 @@ CREATE TABLE gitlab_partitions_dynamic.verification_codes_202308 ( phone text NOT NULL, CONSTRAINT check_9b84e6aaff CHECK ((char_length(code) <= 8)), CONSTRAINT check_ccc542256b CHECK ((char_length(visitor_id_code) <= 64)), - CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 32)) + CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 50)) ); -ALTER TABLE ONLY verification_codes ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_202308 FOR VALUES FROM ('2023-07-31 19:00:00-05') TO ('2023-08-31 19:00:00-05'); +ALTER TABLE ONLY verification_codes ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_202308 FOR VALUES FROM ('2023-08-01 00:00:00+00') TO ('2023-09-01 00:00:00+00'); CREATE TABLE gitlab_partitions_dynamic.verification_codes_202309 ( created_at timestamp with time zone DEFAULT now() NOT NULL, @@ -854,9 +988,9 @@ CREATE TABLE gitlab_partitions_dynamic.verification_codes_202309 ( phone text NOT NULL, CONSTRAINT check_9b84e6aaff CHECK ((char_length(code) <= 8)), CONSTRAINT check_ccc542256b CHECK ((char_length(visitor_id_code) <= 64)), - CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 32)) + CONSTRAINT check_f5684c195b CHECK ((char_length(phone) <= 50)) ); -ALTER TABLE ONLY verification_codes ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_202309 FOR VALUES FROM ('2023-08-31 19:00:00-05') TO ('2023-09-30 19:00:00-05'); +ALTER TABLE ONLY verification_codes ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_202309 FOR VALUES FROM ('2023-09-01 00:00:00+00') TO ('2023-10-01 00:00:00+00'); CREATE TABLE web_hook_logs ( id bigint NOT NULL, @@ -2514,39 +2648,6 @@ CREATE TABLE gitlab_partitions_static.issue_search_data_63 ( ); ALTER TABLE ONLY issue_search_data ATTACH PARTITION gitlab_partitions_static.issue_search_data_63 FOR VALUES WITH (modulus 64, remainder 63); -CREATE TABLE loose_foreign_keys_deleted_records ( - id bigint NOT NULL, - partition bigint DEFAULT 1 NOT NULL, - primary_key_value bigint NOT NULL, - status smallint DEFAULT 1 NOT NULL, - created_at timestamp with time zone DEFAULT now() NOT NULL, - fully_qualified_table_name text NOT NULL, - consume_after timestamp with time zone DEFAULT now(), - CONSTRAINT check_1a541f3235 CHECK ((char_length(fully_qualified_table_name) <= 150)) -) -PARTITION BY LIST (partition); - -CREATE SEQUENCE loose_foreign_keys_deleted_records_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - -ALTER SEQUENCE loose_foreign_keys_deleted_records_id_seq OWNED BY loose_foreign_keys_deleted_records.id; - -CREATE TABLE gitlab_partitions_static.loose_foreign_keys_deleted_records_1 ( - id bigint DEFAULT nextval('loose_foreign_keys_deleted_records_id_seq'::regclass) NOT NULL, - partition bigint DEFAULT 1 NOT NULL, - primary_key_value bigint NOT NULL, - status smallint DEFAULT 1 NOT NULL, - created_at timestamp with time zone DEFAULT now() NOT NULL, - fully_qualified_table_name text NOT NULL, - consume_after timestamp with time zone DEFAULT now(), - CONSTRAINT check_1a541f3235 CHECK ((char_length(fully_qualified_table_name) <= 150)) -); -ALTER TABLE ONLY loose_foreign_keys_deleted_records ATTACH PARTITION gitlab_partitions_static.loose_foreign_keys_deleted_records_1 FOR VALUES IN ('1'); - CREATE TABLE product_analytics_events_experimental ( id bigint NOT NULL, project_id integer NOT NULL, @@ -11293,6 +11394,29 @@ CREATE SEQUENCE alert_management_alert_assignees_id_seq ALTER SEQUENCE alert_management_alert_assignees_id_seq OWNED BY alert_management_alert_assignees.id; +CREATE TABLE alert_management_alert_metric_images ( + id bigint NOT NULL, + alert_id bigint NOT NULL, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + file_store smallint, + file text NOT NULL, + url text, + url_text text, + CONSTRAINT check_2587666252 CHECK ((char_length(url_text) <= 128)), + CONSTRAINT check_4d811d9007 CHECK ((char_length(url) <= 255)), + CONSTRAINT check_70fafae519 CHECK ((char_length(file) <= 255)) +); + +CREATE SEQUENCE alert_management_alert_metric_images_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE alert_management_alert_metric_images_id_seq OWNED BY alert_management_alert_metric_images.id; + CREATE TABLE alert_management_alert_user_mentions ( id bigint NOT NULL, alert_management_alert_id bigint NOT NULL, @@ -11392,6 +11516,30 @@ CREATE SEQUENCE allowed_email_domains_id_seq ALTER SEQUENCE allowed_email_domains_id_seq OWNED BY allowed_email_domains.id; +CREATE TABLE analytics_cycle_analytics_aggregations ( + group_id bigint NOT NULL, + incremental_runtimes_in_seconds integer[] DEFAULT '{}'::integer[] NOT NULL, + incremental_processed_records integer[] DEFAULT '{}'::integer[] NOT NULL, + last_full_run_runtimes_in_seconds integer[] DEFAULT '{}'::integer[] NOT NULL, + last_full_run_processed_records integer[] DEFAULT '{}'::integer[] NOT NULL, + last_incremental_issues_id integer, + last_incremental_merge_requests_id integer, + last_full_run_issues_id integer, + last_full_run_merge_requests_id integer, + last_incremental_run_at timestamp with time zone, + last_incremental_issues_updated_at timestamp with time zone, + last_incremental_merge_requests_updated_at timestamp with time zone, + last_full_run_at timestamp with time zone, + last_full_run_issues_updated_at timestamp with time zone, + last_full_run_mrs_updated_at timestamp with time zone, + last_consistency_check_updated_at timestamp with time zone, + enabled boolean DEFAULT true NOT NULL, + CONSTRAINT chk_rails_1ef688e577 CHECK ((cardinality(incremental_runtimes_in_seconds) <= 10)), + CONSTRAINT chk_rails_7810292ec9 CHECK ((cardinality(last_full_run_processed_records) <= 10)), + CONSTRAINT chk_rails_8b9e89687c CHECK ((cardinality(last_full_run_runtimes_in_seconds) <= 10)), + CONSTRAINT chk_rails_e16bf3913a CHECK ((cardinality(incremental_processed_records) <= 10)) +); + CREATE TABLE analytics_cycle_analytics_group_stages ( id bigint NOT NULL, created_at timestamp with time zone NOT NULL, @@ -11523,7 +11671,7 @@ CREATE TABLE analytics_devops_adoption_snapshots ( runner_configured boolean NOT NULL, pipeline_succeeded boolean NOT NULL, deploy_succeeded boolean NOT NULL, - security_scan_succeeded boolean NOT NULL, + security_scan_succeeded boolean, end_time timestamp with time zone NOT NULL, total_projects_count integer, code_owners_used_count integer, @@ -11799,7 +11947,7 @@ CREATE TABLE application_settings ( throttle_protected_paths_enabled boolean DEFAULT false NOT NULL, throttle_protected_paths_requests_per_period integer DEFAULT 10 NOT NULL, throttle_protected_paths_period_in_seconds integer DEFAULT 60 NOT NULL, - protected_paths character varying(255)[] DEFAULT '{/users/password,/users/sign_in,/api/v3/session.json,/api/v3/session,/api/v4/session.json,/api/v4/session,/users,/users/confirmation,/unsubscribes/,/import/github/personal_access_token,/admin/session,/oauth/authorize,/oauth/token}'::character varying[], + protected_paths character varying(255)[] DEFAULT '{/users/password,/users/sign_in,/api/v3/session.json,/api/v3/session,/api/v4/session.json,/api/v4/session,/users,/users/confirmation,/unsubscribes/,/import/github/personal_access_token,/admin/session}'::character varying[], snowplow_collector_hostname character varying, sourcegraph_enabled boolean DEFAULT false NOT NULL, sourcegraph_url character varying(255), @@ -11882,7 +12030,7 @@ CREATE TABLE application_settings ( kroki_url text, kroki_enabled boolean DEFAULT false NOT NULL, help_page_documentation_base_url text, - container_registry_expiration_policies_worker_capacity integer DEFAULT 0 NOT NULL, + container_registry_expiration_policies_worker_capacity integer DEFAULT 4 NOT NULL, require_admin_approval_after_user_signup boolean DEFAULT true NOT NULL, automatic_purchased_storage_allocation boolean DEFAULT false NOT NULL, encrypted_ci_jwt_signing_key text, @@ -11984,15 +12132,41 @@ CREATE TABLE application_settings ( max_ssh_key_lifetime integer, static_objects_external_storage_auth_token_encrypted text, future_subscriptions jsonb DEFAULT '[]'::jsonb NOT NULL, + user_email_lookup_limit integer DEFAULT 60 NOT NULL, + packages_cleanup_package_file_worker_capacity smallint DEFAULT 2 NOT NULL, + container_registry_import_max_tags_count integer DEFAULT 100 NOT NULL, + container_registry_import_max_retries integer DEFAULT 3 NOT NULL, + container_registry_import_start_max_retries integer DEFAULT 50 NOT NULL, + container_registry_import_max_step_duration integer DEFAULT 300 NOT NULL, + container_registry_import_target_plan text DEFAULT 'free'::text NOT NULL, + container_registry_import_created_before timestamp with time zone DEFAULT '2022-01-23 00:00:00+00'::timestamp with time zone NOT NULL, + runner_token_expiration_interval integer, + group_runner_token_expiration_interval integer, + project_runner_token_expiration_interval integer, + ecdsa_sk_key_restriction integer DEFAULT 0 NOT NULL, + ed25519_sk_key_restriction integer DEFAULT 0 NOT NULL, + users_get_by_id_limit integer DEFAULT 300 NOT NULL, + users_get_by_id_limit_allowlist text[] DEFAULT '{}'::text[] NOT NULL, + container_registry_expiration_policies_caching boolean DEFAULT true NOT NULL, + search_rate_limit integer DEFAULT 30 NOT NULL, + search_rate_limit_unauthenticated integer DEFAULT 10 NOT NULL, + encrypted_database_grafana_api_key bytea, + encrypted_database_grafana_api_key_iv bytea, + database_grafana_api_url text, + database_grafana_tag text, CONSTRAINT app_settings_container_reg_cleanup_tags_max_list_size_positive CHECK ((container_registry_cleanup_tags_service_max_list_size >= 0)), CONSTRAINT app_settings_dep_proxy_ttl_policies_worker_capacity_positive CHECK ((dependency_proxy_ttl_group_policy_worker_capacity >= 0)), CONSTRAINT app_settings_ext_pipeline_validation_service_url_text_limit CHECK ((char_length(external_pipeline_validation_service_url) <= 255)), + CONSTRAINT app_settings_p_cleanup_package_file_worker_capacity_positive CHECK ((packages_cleanup_package_file_worker_capacity >= 0)), CONSTRAINT app_settings_registry_exp_policies_worker_capacity_positive CHECK ((container_registry_expiration_policies_worker_capacity >= 0)), CONSTRAINT app_settings_yaml_max_depth_positive CHECK ((max_yaml_depth > 0)), CONSTRAINT app_settings_yaml_max_size_positive CHECK ((max_yaml_size_bytes > 0)), CONSTRAINT check_17d9558205 CHECK ((char_length(kroki_url) <= 1024)), + CONSTRAINT check_2b820eaac3 CHECK ((char_length(database_grafana_tag) <= 255)), CONSTRAINT check_2dba05b802 CHECK ((char_length(gitpod_url) <= 255)), CONSTRAINT check_32710817e9 CHECK ((char_length(static_objects_external_storage_auth_token_encrypted) <= 255)), + CONSTRAINT check_3455368420 CHECK ((char_length(database_grafana_api_url) <= 255)), + CONSTRAINT check_3559645ae5 CHECK ((char_length(container_registry_import_target_plan) <= 255)), CONSTRAINT check_3def0f1829 CHECK ((char_length(sentry_clientside_dsn) <= 255)), CONSTRAINT check_4f8b811780 CHECK ((char_length(sentry_dsn) <= 255)), CONSTRAINT check_51700b31b5 CHECK ((char_length(default_branch_name) <= 255)), @@ -12263,7 +12437,9 @@ CREATE TABLE audit_events_external_audit_event_destinations ( destination_url text NOT NULL, created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL, - CONSTRAINT check_2feafb9daf CHECK ((char_length(destination_url) <= 255)) + verification_token text, + CONSTRAINT check_2feafb9daf CHECK ((char_length(destination_url) <= 255)), + CONSTRAINT check_8ec80a7d06 CHECK ((char_length(verification_token) <= 24)) ); CREATE SEQUENCE audit_events_external_audit_event_destinations_id_seq @@ -12416,6 +12592,7 @@ CREATE TABLE batched_background_migrations ( job_arguments jsonb DEFAULT '"[]"'::jsonb NOT NULL, total_tuple_count bigint, pause_ms integer DEFAULT 100 NOT NULL, + max_batch_size integer, CONSTRAINT check_5bb0382d6f CHECK ((char_length(column_name) <= 63)), CONSTRAINT check_6b6a06254a CHECK ((char_length(table_name) <= 63)), CONSTRAINT check_batch_size_in_range CHECK ((batch_size >= sub_batch_size)), @@ -12685,7 +12862,8 @@ CREATE TABLE broadcast_messages ( cached_markdown_version integer, dismissable boolean, target_path character varying(255), - broadcast_type smallint DEFAULT 1 NOT NULL + broadcast_type smallint DEFAULT 1 NOT NULL, + target_access_levels integer[] DEFAULT '{}'::integer[] NOT NULL ); CREATE SEQUENCE broadcast_messages_id_seq @@ -13707,7 +13885,11 @@ CREATE TABLE ci_runners ( token_encrypted character varying, public_projects_minutes_cost_factor double precision DEFAULT 0.0 NOT NULL, private_projects_minutes_cost_factor double precision DEFAULT 1.0 NOT NULL, - config jsonb DEFAULT '{}'::jsonb NOT NULL + config jsonb DEFAULT '{}'::jsonb NOT NULL, + executor_type smallint, + maintainer_note text, + token_expires_at timestamp with time zone, + CONSTRAINT check_ce275cee06 CHECK ((char_length(maintainer_note) <= 1024)) ); CREATE SEQUENCE ci_runners_id_seq @@ -13738,6 +13920,29 @@ CREATE SEQUENCE ci_running_builds_id_seq ALTER SEQUENCE ci_running_builds_id_seq OWNED BY ci_running_builds.id; +CREATE TABLE ci_secure_files ( + id bigint NOT NULL, + project_id bigint NOT NULL, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + file_store smallint DEFAULT 1 NOT NULL, + permissions smallint DEFAULT 0 NOT NULL, + name text NOT NULL, + file text NOT NULL, + checksum bytea NOT NULL, + CONSTRAINT check_320790634d CHECK ((char_length(file) <= 255)), + CONSTRAINT check_402c7b4a56 CHECK ((char_length(name) <= 255)) +); + +CREATE SEQUENCE ci_secure_files_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE ci_secure_files_id_seq OWNED BY ci_secure_files.id; + CREATE TABLE ci_sources_pipelines ( id integer NOT NULL, project_id integer, @@ -13919,6 +14124,7 @@ CREATE TABLE cluster_agent_tokens ( description text, name text, last_used_at timestamp with time zone, + status smallint DEFAULT 0 NOT NULL, CONSTRAINT check_0fb634d04d CHECK ((name IS NOT NULL)), CONSTRAINT check_2b79dbb315 CHECK ((char_length(name) <= 255)), CONSTRAINT check_4e4ec5070a CHECK ((char_length(description) <= 1024)), @@ -14427,7 +14633,19 @@ CREATE TABLE container_repositories ( status smallint, expiration_policy_started_at timestamp with time zone, expiration_policy_cleanup_status smallint DEFAULT 0 NOT NULL, - expiration_policy_completed_at timestamp with time zone + expiration_policy_completed_at timestamp with time zone, + migration_pre_import_started_at timestamp with time zone, + migration_pre_import_done_at timestamp with time zone, + migration_import_started_at timestamp with time zone, + migration_import_done_at timestamp with time zone, + migration_aborted_at timestamp with time zone, + migration_skipped_at timestamp with time zone, + migration_retries_count integer DEFAULT 0 NOT NULL, + migration_skipped_reason smallint, + migration_state text DEFAULT 'default'::text NOT NULL, + migration_aborted_in_state text, + CONSTRAINT check_13c58fe73a CHECK ((char_length(migration_state) <= 255)), + CONSTRAINT check_97f0249439 CHECK ((char_length(migration_aborted_in_state) <= 255)) ); CREATE SEQUENCE container_repositories_id_seq @@ -14747,6 +14965,8 @@ CREATE TABLE dast_site_profiles ( auth_password_field text, auth_username text, target_type smallint DEFAULT 0 NOT NULL, + scan_method smallint DEFAULT 0 NOT NULL, + scan_file_path text, CONSTRAINT check_5203110fee CHECK ((char_length(auth_username_field) <= 255)), CONSTRAINT check_6cfab17b48 CHECK ((char_length(name) <= 255)), CONSTRAINT check_c329dffdba CHECK ((char_length(auth_password_field) <= 255)), @@ -14973,7 +15193,9 @@ CREATE TABLE deployment_approvals ( user_id bigint NOT NULL, created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL, - status smallint NOT NULL + status smallint NOT NULL, + comment text, + CONSTRAINT check_e2eb6a17d8 CHECK ((char_length(comment) <= 255)) ); CREATE SEQUENCE deployment_approvals_id_seq @@ -15167,6 +15389,7 @@ CREATE TABLE dora_daily_metrics ( date date NOT NULL, deployment_frequency integer, lead_time_for_changes_in_seconds integer, + time_to_restore_service_in_seconds integer, CONSTRAINT dora_daily_metrics_deployment_frequency_positive CHECK ((deployment_frequency >= 0)), CONSTRAINT dora_daily_metrics_lead_time_for_changes_in_seconds_positive CHECK ((lead_time_for_changes_in_seconds >= 0)) ); @@ -16287,6 +16510,22 @@ CREATE SEQUENCE grafana_integrations_id_seq ALTER SEQUENCE grafana_integrations_id_seq OWNED BY grafana_integrations.id; +CREATE TABLE group_crm_settings ( + group_id bigint NOT NULL, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + enabled boolean DEFAULT false NOT NULL +); + +CREATE SEQUENCE group_crm_settings_group_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE group_crm_settings_group_id_seq OWNED BY group_crm_settings.group_id; + CREATE TABLE group_custom_attributes ( id integer NOT NULL, created_at timestamp with time zone NOT NULL, @@ -16372,6 +16611,13 @@ CREATE SEQUENCE group_deploy_tokens_id_seq ALTER SEQUENCE group_deploy_tokens_id_seq OWNED BY group_deploy_tokens.id; +CREATE TABLE group_features ( + group_id bigint NOT NULL, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + wiki_access_level smallint DEFAULT 20 NOT NULL +); + CREATE TABLE group_group_links ( id bigint NOT NULL, created_at timestamp with time zone NOT NULL, @@ -16764,7 +17010,6 @@ ALTER SEQUENCE insights_id_seq OWNED BY insights.id; CREATE TABLE integrations ( id integer NOT NULL, - type character varying, project_id integer, created_at timestamp without time zone, updated_at timestamp without time zone, @@ -16793,6 +17038,8 @@ CREATE TABLE integrations ( vulnerability_events boolean DEFAULT false NOT NULL, type_new text, archive_trace_events boolean DEFAULT false NOT NULL, + encrypted_properties bytea, + encrypted_properties_iv bytea, CONSTRAINT check_a948a0aa7e CHECK ((char_length(type_new) <= 255)) ); @@ -16846,6 +17093,8 @@ CREATE TABLE issuable_metric_images ( file_store smallint, file text NOT NULL, url text, + url_text text, + CONSTRAINT check_3bc6d47661 CHECK ((char_length(url_text) <= 128)), CONSTRAINT check_5b3011e234 CHECK ((char_length(url) <= 255)), CONSTRAINT check_7ed527062f CHECK ((char_length(file) <= 255)) ); @@ -17505,7 +17754,8 @@ CREATE TABLE members ( ldap boolean DEFAULT false NOT NULL, override boolean DEFAULT false NOT NULL, invite_email_success boolean DEFAULT true NOT NULL, - state smallint DEFAULT 0 + state smallint DEFAULT 0, + member_namespace_id bigint ); CREATE SEQUENCE members_id_seq @@ -17523,7 +17773,8 @@ CREATE TABLE merge_request_assignees ( user_id integer NOT NULL, merge_request_id integer NOT NULL, created_at timestamp with time zone, - state smallint DEFAULT 0 NOT NULL + state smallint DEFAULT 0 NOT NULL, + updated_state_by_user_id bigint ); CREATE SEQUENCE merge_request_assignees_id_seq @@ -17752,7 +18003,8 @@ CREATE TABLE merge_request_reviewers ( user_id bigint NOT NULL, merge_request_id bigint NOT NULL, created_at timestamp with time zone NOT NULL, - state smallint DEFAULT 0 NOT NULL + state smallint DEFAULT 0 NOT NULL, + updated_state_by_user_id bigint ); CREATE SEQUENCE merge_request_reviewers_id_seq @@ -17849,7 +18101,8 @@ CREATE TABLE merge_requests_compliance_violations ( id bigint NOT NULL, violating_user_id bigint NOT NULL, merge_request_id bigint NOT NULL, - reason smallint NOT NULL + reason smallint NOT NULL, + severity_level smallint DEFAULT 0 NOT NULL ); CREATE SEQUENCE merge_requests_compliance_violations_id_seq @@ -18025,7 +18278,8 @@ CREATE TABLE namespace_root_storage_statistics ( packages_size bigint DEFAULT 0 NOT NULL, snippets_size bigint DEFAULT 0 NOT NULL, pipeline_artifacts_size bigint DEFAULT 0 NOT NULL, - uploads_size bigint DEFAULT 0 NOT NULL + uploads_size bigint DEFAULT 0 NOT NULL, + dependency_proxy_size bigint DEFAULT 0 NOT NULL ); CREATE SEQUENCE namespace_root_storage_statistics_namespace_id_seq @@ -18053,6 +18307,9 @@ CREATE TABLE namespace_settings ( new_user_signups_cap integer, setup_for_company boolean, jobs_to_be_done smallint, + runner_token_expiration_interval integer, + subgroup_runner_token_expiration_interval integer, + project_runner_token_expiration_interval integer, CONSTRAINT check_0ba93c78c7 CHECK ((char_length(default_branch_name) <= 255)) ); @@ -18062,7 +18319,8 @@ CREATE TABLE namespace_statistics ( shared_runners_seconds integer DEFAULT 0 NOT NULL, shared_runners_seconds_last_reset timestamp without time zone, storage_size bigint DEFAULT 0 NOT NULL, - wiki_size bigint DEFAULT 0 NOT NULL + wiki_size bigint DEFAULT 0 NOT NULL, + dependency_proxy_size bigint DEFAULT 0 NOT NULL ); CREATE SEQUENCE namespace_statistics_id_seq @@ -18364,7 +18622,14 @@ CREATE TABLE onboarding_progresses ( issue_auto_closed_at timestamp with time zone, repository_imported_at timestamp with time zone, repository_mirrored_at timestamp with time zone, - issue_created_at timestamp with time zone + issue_created_at timestamp with time zone, + secure_dependency_scanning_run_at timestamp with time zone, + secure_container_scanning_run_at timestamp with time zone, + secure_dast_run_at timestamp with time zone, + secure_secret_detection_run_at timestamp with time zone, + secure_coverage_fuzzing_run_at timestamp with time zone, + secure_cluster_image_scanning_run_at timestamp with time zone, + secure_api_fuzzing_run_at timestamp with time zone ); CREATE SEQUENCE onboarding_progresses_id_seq @@ -19004,6 +19269,7 @@ CREATE TABLE packages_package_files ( verification_checksum bytea, verification_state smallint DEFAULT 0 NOT NULL, verification_started_at timestamp with time zone, + status smallint DEFAULT 0 NOT NULL, CONSTRAINT check_4c5e6bb0b3 CHECK ((file_store IS NOT NULL)) ); @@ -19039,7 +19305,7 @@ ALTER SEQUENCE packages_packages_id_seq OWNED BY packages_packages.id; CREATE TABLE packages_pypi_metadata ( package_id bigint NOT NULL, - required_python text, + required_python text DEFAULT ''::text, CONSTRAINT check_0d9aed55b2 CHECK ((required_python IS NOT NULL)), CONSTRAINT check_379019d5da CHECK ((char_length(required_python) <= 255)) ); @@ -19213,28 +19479,6 @@ CREATE SEQUENCE pages_domains_id_seq ALTER SEQUENCE pages_domains_id_seq OWNED BY pages_domains.id; -CREATE TABLE partitioned_foreign_keys ( - id bigint NOT NULL, - cascade_delete boolean DEFAULT true NOT NULL, - from_table text NOT NULL, - from_column text NOT NULL, - to_table text NOT NULL, - to_column text NOT NULL, - CONSTRAINT check_2c2e02a62b CHECK ((char_length(from_column) <= 63)), - CONSTRAINT check_40738efb57 CHECK ((char_length(to_table) <= 63)), - CONSTRAINT check_741676d405 CHECK ((char_length(from_table) <= 63)), - CONSTRAINT check_7e98be694f CHECK ((char_length(to_column) <= 63)) -); - -CREATE SEQUENCE partitioned_foreign_keys_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - -ALTER SEQUENCE partitioned_foreign_keys_id_seq OWNED BY partitioned_foreign_keys.id; - CREATE TABLE path_locks ( id integer NOT NULL, path character varying NOT NULL, @@ -19714,6 +19958,25 @@ CREATE SEQUENCE project_auto_devops_id_seq ALTER SEQUENCE project_auto_devops_id_seq OWNED BY project_auto_devops.id; +CREATE TABLE project_build_artifacts_size_refreshes ( + id bigint NOT NULL, + project_id bigint NOT NULL, + last_job_artifact_id bigint, + state smallint DEFAULT 1 NOT NULL, + refresh_started_at timestamp with time zone, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL +); + +CREATE SEQUENCE project_build_artifacts_size_refreshes_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE project_build_artifacts_size_refreshes_id_seq OWNED BY project_build_artifacts_size_refreshes.id; + CREATE TABLE project_ci_cd_settings ( id integer NOT NULL, project_id integer NOT NULL, @@ -19725,7 +19988,8 @@ CREATE TABLE project_ci_cd_settings ( auto_rollback_enabled boolean DEFAULT false NOT NULL, keep_latest_artifact boolean DEFAULT true NOT NULL, restrict_user_defined_variables boolean DEFAULT false NOT NULL, - job_token_scope_enabled boolean DEFAULT false NOT NULL + job_token_scope_enabled boolean DEFAULT false NOT NULL, + runner_token_expiration_interval integer ); CREATE SEQUENCE project_ci_cd_settings_id_seq @@ -19874,7 +20138,8 @@ CREATE TABLE project_features ( requirements_access_level integer DEFAULT 20 NOT NULL, operations_access_level integer DEFAULT 20 NOT NULL, security_and_compliance_access_level integer DEFAULT 10 NOT NULL, - container_registry_access_level integer DEFAULT 0 NOT NULL + container_registry_access_level integer DEFAULT 0 NOT NULL, + package_registry_access_level integer DEFAULT 0 NOT NULL ); CREATE SEQUENCE project_features_id_seq @@ -20078,6 +20343,7 @@ CREATE TABLE project_settings ( merge_commit_template text, has_shimo boolean DEFAULT false NOT NULL, squash_commit_template text, + legacy_open_source_license_available boolean DEFAULT true NOT NULL, CONSTRAINT check_3a03e7557a CHECK ((char_length(previous_default_branch) <= 4096)), CONSTRAINT check_b09644994b CHECK ((char_length(squash_commit_template) <= 500)), CONSTRAINT check_eaf7cfb6a7 CHECK ((char_length(merge_commit_template) <= 500)) @@ -20227,7 +20493,8 @@ CREATE TABLE projects ( remove_source_branch_after_merge boolean, suggestion_commit_message character varying(255), autoclose_referenced_issues boolean, - project_namespace_id bigint + project_namespace_id bigint, + hidden boolean DEFAULT false NOT NULL ); CREATE SEQUENCE projects_id_seq @@ -20402,6 +20669,28 @@ CREATE SEQUENCE protected_branches_id_seq ALTER SEQUENCE protected_branches_id_seq OWNED BY protected_branches.id; +CREATE TABLE protected_environment_approval_rules ( + id bigint NOT NULL, + protected_environment_id bigint NOT NULL, + user_id bigint, + group_id bigint, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + access_level smallint, + required_approvals smallint NOT NULL, + CONSTRAINT chk_rails_bed75249bc CHECK ((((access_level IS NOT NULL) AND (group_id IS NULL) AND (user_id IS NULL)) OR ((user_id IS NOT NULL) AND (access_level IS NULL) AND (group_id IS NULL)) OR ((group_id IS NOT NULL) AND (user_id IS NULL) AND (access_level IS NULL)))), + CONSTRAINT chk_rails_cfa90ae3b5 CHECK ((required_approvals > 0)) +); + +CREATE SEQUENCE protected_environment_approval_rules_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE protected_environment_approval_rules_id_seq OWNED BY protected_environment_approval_rules.id; + CREATE TABLE protected_environment_deploy_access_levels ( id integer NOT NULL, created_at timestamp with time zone NOT NULL, @@ -20430,7 +20719,8 @@ CREATE TABLE protected_environments ( name character varying NOT NULL, group_id bigint, required_approval_count integer DEFAULT 0 NOT NULL, - CONSTRAINT protected_environments_project_or_group_existence CHECK (((project_id IS NULL) <> (group_id IS NULL))) + CONSTRAINT protected_environments_project_or_group_existence CHECK (((project_id IS NULL) <> (group_id IS NULL))), + CONSTRAINT protected_environments_required_approval_count_positive CHECK ((required_approval_count >= 0)) ); CREATE SEQUENCE protected_environments_id_seq @@ -20563,6 +20853,24 @@ CREATE SEQUENCE redirect_routes_id_seq ALTER SEQUENCE redirect_routes_id_seq OWNED BY redirect_routes.id; +CREATE TABLE related_epic_links ( + id bigint NOT NULL, + source_id bigint NOT NULL, + target_id bigint NOT NULL, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + link_type smallint DEFAULT 0 NOT NULL +); + +CREATE SEQUENCE related_epic_links_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE related_epic_links_id_seq OWNED BY related_epic_links.id; + CREATE TABLE release_links ( id bigint NOT NULL, release_id integer NOT NULL, @@ -20834,7 +21142,8 @@ CREATE TABLE routes ( path character varying NOT NULL, created_at timestamp without time zone, updated_at timestamp without time zone, - name character varying + name character varying, + namespace_id bigint ); CREATE SEQUENCE routes_id_seq @@ -20889,6 +21198,26 @@ CREATE SEQUENCE saml_providers_id_seq ALTER SEQUENCE saml_providers_id_seq OWNED BY saml_providers.id; +CREATE TABLE saved_replies ( + id bigint NOT NULL, + user_id bigint NOT NULL, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + name text NOT NULL, + content text NOT NULL, + CONSTRAINT check_0cb57dc22a CHECK ((char_length(content) <= 10000)), + CONSTRAINT check_2eb3366d7f CHECK ((char_length(name) <= 255)) +); + +CREATE SEQUENCE saved_replies_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE saved_replies_id_seq OWNED BY saved_replies.id; + CREATE TABLE scim_identities ( id bigint NOT NULL, group_id bigint NOT NULL, @@ -20934,9 +21263,9 @@ CREATE TABLE security_findings ( confidence smallint NOT NULL, project_fingerprint text, deduplicated boolean DEFAULT false NOT NULL, - "position" integer, uuid uuid, overridden_uuid uuid, + CONSTRAINT check_6c2851a8c9 CHECK ((uuid IS NOT NULL)), CONSTRAINT check_b9508c6df8 CHECK ((char_length(project_fingerprint) <= 40)) ); @@ -20951,11 +21280,13 @@ ALTER SEQUENCE security_findings_id_seq OWNED BY security_findings.id; CREATE TABLE security_orchestration_policy_configurations ( id bigint NOT NULL, - project_id bigint NOT NULL, + project_id bigint, security_policy_management_project_id bigint NOT NULL, created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL, - configured_at timestamp with time zone + configured_at timestamp with time zone, + namespace_id bigint, + CONSTRAINT cop_configs_project_or_namespace_existence CHECK (((project_id IS NULL) <> (namespace_id IS NULL))) ); COMMENT ON TABLE security_orchestration_policy_configurations IS '{"owner":"group::container security","description":"Configuration used to store relationship between project and security policy repository"}'; @@ -21015,6 +21346,47 @@ CREATE SEQUENCE security_scans_id_seq ALTER SEQUENCE security_scans_id_seq OWNED BY security_scans.id; +CREATE TABLE security_training_providers ( + id bigint NOT NULL, + name text NOT NULL, + description text, + url text NOT NULL, + logo_url text, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + CONSTRAINT check_544b3dc935 CHECK ((char_length(url) <= 512)), + CONSTRAINT check_6fe222f071 CHECK ((char_length(logo_url) <= 512)), + CONSTRAINT check_a8ff21ced5 CHECK ((char_length(description) <= 512)), + CONSTRAINT check_dae433eed6 CHECK ((char_length(name) <= 256)) +); + +CREATE SEQUENCE security_training_providers_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE security_training_providers_id_seq OWNED BY security_training_providers.id; + +CREATE TABLE security_trainings ( + id bigint NOT NULL, + project_id bigint NOT NULL, + provider_id bigint NOT NULL, + is_primary boolean DEFAULT false NOT NULL, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL +); + +CREATE SEQUENCE security_trainings_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE security_trainings_id_seq OWNED BY security_trainings.id; + CREATE TABLE self_managed_prometheus_alert_events ( id bigint NOT NULL, project_id bigint NOT NULL, @@ -21310,7 +21682,7 @@ CREATE TABLE sprints ( group_id bigint, iid integer NOT NULL, cached_markdown_version integer, - title text NOT NULL, + title text, title_html text, description text, description_html text, @@ -21335,7 +21707,8 @@ CREATE TABLE status_check_responses ( merge_request_id bigint NOT NULL, external_approval_rule_id bigint, sha bytea NOT NULL, - external_status_check_id bigint NOT NULL + external_status_check_id bigint NOT NULL, + status smallint DEFAULT 0 NOT NULL ); CREATE SEQUENCE status_check_responses_id_seq @@ -21567,7 +21940,7 @@ CREATE TABLE timelogs ( updated_at timestamp without time zone NOT NULL, issue_id integer, merge_request_id integer, - spent_at timestamp with time zone, + spent_at timestamp with time zone DEFAULT now(), note_id integer, project_id integer, summary text, @@ -21635,6 +22008,7 @@ CREATE TABLE topics ( avatar text, description text, total_projects_count bigint DEFAULT 0 NOT NULL, + non_private_projects_count bigint DEFAULT 0 NOT NULL, CONSTRAINT check_26753fb43a CHECK ((char_length(avatar) <= 255)), CONSTRAINT check_5d1a07c8c8 CHECK ((char_length(description) <= 1024)), CONSTRAINT check_7a90d4c757 CHECK ((char_length(name) <= 255)) @@ -21814,7 +22188,7 @@ CREATE TABLE user_credit_card_validations ( network text, CONSTRAINT check_1765e2b30f CHECK ((char_length(network) <= 32)), CONSTRAINT check_3eea080c91 CHECK (((last_digits >= 0) AND (last_digits <= 9999))), - CONSTRAINT check_eafe45d88b CHECK ((char_length(holder_name) <= 26)) + CONSTRAINT check_cc0c8dc0fe CHECK ((char_length(holder_name) <= 50)) ); CREATE TABLE user_custom_attributes ( @@ -21847,8 +22221,9 @@ CREATE TABLE user_details ( pronunciation text, registration_objective smallint, phone text, + requires_credit_card_verification boolean DEFAULT false NOT NULL, CONSTRAINT check_245664af82 CHECK ((char_length(webauthn_xid) <= 100)), - CONSTRAINT check_a73b398c60 CHECK ((char_length(phone) <= 32)), + CONSTRAINT check_a73b398c60 CHECK ((char_length(phone) <= 50)), CONSTRAINT check_b132136b01 CHECK ((char_length(other_role) <= 100)), CONSTRAINT check_eeeaf8d4f0 CHECK ((char_length(pronouns) <= 50)), CONSTRAINT check_f932ed37db CHECK ((char_length(pronunciation) <= 255)) @@ -21944,7 +22319,11 @@ CREATE TABLE user_preferences ( experience_level smallint, view_diffs_file_by_file boolean DEFAULT false NOT NULL, gitpod_enabled boolean DEFAULT false NOT NULL, - markdown_surround_selection boolean DEFAULT true NOT NULL + markdown_surround_selection boolean DEFAULT true NOT NULL, + diffs_deletion_color text, + diffs_addition_color text, + CONSTRAINT check_89bf269f41 CHECK ((char_length(diffs_deletion_color) <= 7)), + CONSTRAINT check_d07ccd35f7 CHECK ((char_length(diffs_addition_color) <= 7)) ); CREATE SEQUENCE user_preferences_id_seq @@ -22279,140 +22658,12 @@ CREATE SEQUENCE vulnerability_feedback_id_seq ALTER SEQUENCE vulnerability_feedback_id_seq OWNED BY vulnerability_feedback.id; -CREATE TABLE vulnerability_finding_evidence_assets ( - id bigint NOT NULL, - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, - vulnerability_finding_evidence_id bigint NOT NULL, - type text, - name text, - url text, - CONSTRAINT check_5adf5d69de CHECK ((char_length(type) <= 2048)), - CONSTRAINT check_839f29d7ca CHECK ((char_length(name) <= 2048)), - CONSTRAINT check_9272d912c0 CHECK ((char_length(url) <= 2048)) -); - -CREATE SEQUENCE vulnerability_finding_evidence_assets_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - -ALTER SEQUENCE vulnerability_finding_evidence_assets_id_seq OWNED BY vulnerability_finding_evidence_assets.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, - updated_at timestamp with time zone NOT NULL, - vulnerability_finding_evidence_id bigint, - method text, - url text, - body text, - vulnerability_finding_evidence_supporting_message_id bigint, - CONSTRAINT check_7e37f2d01a CHECK ((char_length(body) <= 2048)), - CONSTRAINT check_8152fbb236 CHECK ((char_length(url) <= 2048)), - CONSTRAINT check_d9d11300f4 CHECK ((char_length(method) <= 32)) -); - -CREATE SEQUENCE vulnerability_finding_evidence_requests_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - -ALTER SEQUENCE vulnerability_finding_evidence_requests_id_seq OWNED BY vulnerability_finding_evidence_requests.id; - -CREATE TABLE vulnerability_finding_evidence_responses ( - id bigint NOT NULL, - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, - vulnerability_finding_evidence_id bigint, - status_code integer, - reason_phrase text, - body text, - vulnerability_finding_evidence_supporting_message_id bigint, - CONSTRAINT check_58b124ab48 CHECK ((char_length(reason_phrase) <= 2048)), - CONSTRAINT check_76bac0c32b CHECK ((char_length(body) <= 2048)) -); - -CREATE SEQUENCE vulnerability_finding_evidence_responses_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - -ALTER SEQUENCE vulnerability_finding_evidence_responses_id_seq OWNED BY vulnerability_finding_evidence_responses.id; - -CREATE TABLE vulnerability_finding_evidence_sources ( - id bigint NOT NULL, - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, - vulnerability_finding_evidence_id bigint NOT NULL, - name text, - url text, - CONSTRAINT check_0fe01298d6 CHECK ((char_length(url) <= 2048)), - CONSTRAINT check_86b537ba1a CHECK ((char_length(name) <= 2048)) -); - -CREATE SEQUENCE vulnerability_finding_evidence_sources_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - -ALTER SEQUENCE vulnerability_finding_evidence_sources_id_seq OWNED BY vulnerability_finding_evidence_sources.id; - -CREATE TABLE vulnerability_finding_evidence_supporting_messages ( - id bigint NOT NULL, - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, - vulnerability_finding_evidence_id bigint NOT NULL, - name text, - CONSTRAINT check_fa33b9ae85 CHECK ((char_length(name) <= 2048)) -); - -CREATE SEQUENCE vulnerability_finding_evidence_supporting_messages_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - -ALTER SEQUENCE vulnerability_finding_evidence_supporting_messages_id_seq OWNED BY vulnerability_finding_evidence_supporting_messages.id; - CREATE TABLE vulnerability_finding_evidences ( id bigint NOT NULL, created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL, vulnerability_occurrence_id bigint NOT NULL, - summary text, - data jsonb DEFAULT '{}'::jsonb NOT NULL, - CONSTRAINT check_5773b236fb CHECK ((char_length(summary) <= 8000000)) + data jsonb DEFAULT '{}'::jsonb NOT NULL ); CREATE SEQUENCE vulnerability_finding_evidences_id_seq @@ -22650,7 +22901,9 @@ CREATE TABLE vulnerability_reads ( resolved_on_default_branch boolean DEFAULT false NOT NULL, uuid uuid NOT NULL, location_image text, - CONSTRAINT check_380451bdbe CHECK ((char_length(location_image) <= 2048)) + cluster_agent_id text, + CONSTRAINT check_380451bdbe CHECK ((char_length(location_image) <= 2048)), + CONSTRAINT check_a105eb825a CHECK ((char_length(cluster_agent_id) <= 10)) ); CREATE SEQUENCE vulnerability_reads_id_seq @@ -22988,6 +23241,8 @@ ALTER TABLE ONLY agent_project_authorizations ALTER COLUMN id SET DEFAULT nextva ALTER TABLE ONLY alert_management_alert_assignees ALTER COLUMN id SET DEFAULT nextval('alert_management_alert_assignees_id_seq'::regclass); +ALTER TABLE ONLY alert_management_alert_metric_images ALTER COLUMN id SET DEFAULT nextval('alert_management_alert_metric_images_id_seq'::regclass); + ALTER TABLE ONLY alert_management_alert_user_mentions ALTER COLUMN id SET DEFAULT nextval('alert_management_alert_user_mentions_id_seq'::regclass); ALTER TABLE ONLY alert_management_alerts ALTER COLUMN id SET DEFAULT nextval('alert_management_alerts_id_seq'::regclass); @@ -23182,6 +23437,8 @@ ALTER TABLE ONLY ci_runners ALTER COLUMN id SET DEFAULT nextval('ci_runners_id_s ALTER TABLE ONLY ci_running_builds ALTER COLUMN id SET DEFAULT nextval('ci_running_builds_id_seq'::regclass); +ALTER TABLE ONLY ci_secure_files ALTER COLUMN id SET DEFAULT nextval('ci_secure_files_id_seq'::regclass); + ALTER TABLE ONLY ci_sources_pipelines ALTER COLUMN id SET DEFAULT nextval('ci_sources_pipelines_id_seq'::regclass); ALTER TABLE ONLY ci_sources_projects ALTER COLUMN id SET DEFAULT nextval('ci_sources_projects_id_seq'::regclass); @@ -23406,6 +23663,8 @@ ALTER TABLE ONLY gpg_signatures ALTER COLUMN id SET DEFAULT nextval('gpg_signatu ALTER TABLE ONLY grafana_integrations ALTER COLUMN id SET DEFAULT nextval('grafana_integrations_id_seq'::regclass); +ALTER TABLE ONLY group_crm_settings ALTER COLUMN group_id SET DEFAULT nextval('group_crm_settings_group_id_seq'::regclass); + ALTER TABLE ONLY group_custom_attributes ALTER COLUMN id SET DEFAULT nextval('group_custom_attributes_id_seq'::regclass); ALTER TABLE ONLY group_deploy_keys ALTER COLUMN id SET DEFAULT nextval('group_deploy_keys_id_seq'::regclass); @@ -23654,8 +23913,6 @@ ALTER TABLE ONLY pages_domain_acme_orders ALTER COLUMN id SET DEFAULT nextval('p ALTER TABLE ONLY pages_domains ALTER COLUMN id SET DEFAULT nextval('pages_domains_id_seq'::regclass); -ALTER TABLE ONLY partitioned_foreign_keys ALTER COLUMN id SET DEFAULT nextval('partitioned_foreign_keys_id_seq'::regclass); - ALTER TABLE ONLY path_locks ALTER COLUMN id SET DEFAULT nextval('path_locks_id_seq'::regclass); ALTER TABLE ONLY personal_access_tokens ALTER COLUMN id SET DEFAULT nextval('personal_access_tokens_id_seq'::regclass); @@ -23680,6 +23937,8 @@ ALTER TABLE ONLY project_aliases ALTER COLUMN id SET DEFAULT nextval('project_al ALTER TABLE ONLY project_auto_devops ALTER COLUMN id SET DEFAULT nextval('project_auto_devops_id_seq'::regclass); +ALTER TABLE ONLY project_build_artifacts_size_refreshes ALTER COLUMN id SET DEFAULT nextval('project_build_artifacts_size_refreshes_id_seq'::regclass); + ALTER TABLE ONLY project_ci_cd_settings ALTER COLUMN id SET DEFAULT nextval('project_ci_cd_settings_id_seq'::regclass); ALTER TABLE ONLY project_ci_feature_usages ALTER COLUMN id SET DEFAULT nextval('project_ci_feature_usages_id_seq'::regclass); @@ -23734,6 +23993,8 @@ ALTER TABLE ONLY protected_branch_unprotect_access_levels ALTER COLUMN id SET DE ALTER TABLE ONLY protected_branches ALTER COLUMN id SET DEFAULT nextval('protected_branches_id_seq'::regclass); +ALTER TABLE ONLY protected_environment_approval_rules ALTER COLUMN id SET DEFAULT nextval('protected_environment_approval_rules_id_seq'::regclass); + ALTER TABLE ONLY protected_environment_deploy_access_levels ALTER COLUMN id SET DEFAULT nextval('protected_environment_deploy_access_levels_id_seq'::regclass); ALTER TABLE ONLY protected_environments ALTER COLUMN id SET DEFAULT nextval('protected_environments_id_seq'::regclass); @@ -23748,6 +24009,8 @@ ALTER TABLE ONLY raw_usage_data ALTER COLUMN id SET DEFAULT nextval('raw_usage_d ALTER TABLE ONLY redirect_routes ALTER COLUMN id SET DEFAULT nextval('redirect_routes_id_seq'::regclass); +ALTER TABLE ONLY related_epic_links ALTER COLUMN id SET DEFAULT nextval('related_epic_links_id_seq'::regclass); + ALTER TABLE ONLY release_links ALTER COLUMN id SET DEFAULT nextval('release_links_id_seq'::regclass); ALTER TABLE ONLY releases ALTER COLUMN id SET DEFAULT nextval('releases_id_seq'::regclass); @@ -23778,6 +24041,8 @@ ALTER TABLE ONLY saml_group_links ALTER COLUMN id SET DEFAULT nextval('saml_grou ALTER TABLE ONLY saml_providers ALTER COLUMN id SET DEFAULT nextval('saml_providers_id_seq'::regclass); +ALTER TABLE ONLY saved_replies ALTER COLUMN id SET DEFAULT nextval('saved_replies_id_seq'::regclass); + ALTER TABLE ONLY scim_identities ALTER COLUMN id SET DEFAULT nextval('scim_identities_id_seq'::regclass); ALTER TABLE ONLY scim_oauth_access_tokens ALTER COLUMN id SET DEFAULT nextval('scim_oauth_access_tokens_id_seq'::regclass); @@ -23790,6 +24055,10 @@ ALTER TABLE ONLY security_orchestration_policy_rule_schedules ALTER COLUMN id SE ALTER TABLE ONLY security_scans ALTER COLUMN id SET DEFAULT nextval('security_scans_id_seq'::regclass); +ALTER TABLE ONLY security_training_providers ALTER COLUMN id SET DEFAULT nextval('security_training_providers_id_seq'::regclass); + +ALTER TABLE ONLY security_trainings ALTER COLUMN id SET DEFAULT nextval('security_trainings_id_seq'::regclass); + ALTER TABLE ONLY self_managed_prometheus_alert_events ALTER COLUMN id SET DEFAULT nextval('self_managed_prometheus_alert_events_id_seq'::regclass); ALTER TABLE ONLY sent_notifications ALTER COLUMN id SET DEFAULT nextval('sent_notifications_id_seq'::regclass); @@ -23892,18 +24161,6 @@ 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_assets ALTER COLUMN id SET DEFAULT nextval('vulnerability_finding_evidence_assets_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); - -ALTER TABLE ONLY vulnerability_finding_evidence_sources ALTER COLUMN id SET DEFAULT nextval('vulnerability_finding_evidence_sources_id_seq'::regclass); - -ALTER TABLE ONLY vulnerability_finding_evidence_supporting_messages ALTER COLUMN id SET DEFAULT nextval('vulnerability_finding_evidence_supporting_messages_id_seq'::regclass); - ALTER TABLE ONLY vulnerability_finding_evidences ALTER COLUMN id SET DEFAULT nextval('vulnerability_finding_evidences_id_seq'::regclass); ALTER TABLE ONLY vulnerability_finding_links ALTER COLUMN id SET DEFAULT nextval('vulnerability_finding_links_id_seq'::regclass); @@ -24093,6 +24350,12 @@ ALTER TABLE ONLY gitlab_partitions_dynamic.incident_management_pending_issue_esc ALTER TABLE ONLY gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202309 ADD CONSTRAINT incident_management_pending_issue_escalations_202309_pkey PRIMARY KEY (id, process_at); +ALTER TABLE ONLY loose_foreign_keys_deleted_records + ADD CONSTRAINT loose_foreign_keys_deleted_records_pkey PRIMARY KEY (partition, id); + +ALTER TABLE ONLY gitlab_partitions_dynamic.loose_foreign_keys_deleted_records_1 + ADD CONSTRAINT loose_foreign_keys_deleted_records_1_pkey PRIMARY KEY (partition, id); + ALTER TABLE ONLY verification_codes ADD CONSTRAINT verification_codes_pkey PRIMARY KEY (created_at, visitor_id_code, code, phone); @@ -24552,12 +24815,6 @@ ALTER TABLE ONLY gitlab_partitions_static.issue_search_data_62 ALTER TABLE ONLY gitlab_partitions_static.issue_search_data_63 ADD CONSTRAINT issue_search_data_63_pkey PRIMARY KEY (project_id, issue_id); -ALTER TABLE ONLY loose_foreign_keys_deleted_records - ADD CONSTRAINT loose_foreign_keys_deleted_records_pkey PRIMARY KEY (partition, id); - -ALTER TABLE ONLY gitlab_partitions_static.loose_foreign_keys_deleted_records_1 - ADD CONSTRAINT loose_foreign_keys_deleted_records_1_pkey PRIMARY KEY (partition, id); - ALTER TABLE ONLY product_analytics_events_experimental ADD CONSTRAINT product_analytics_events_experimental_pkey PRIMARY KEY (id, project_id); @@ -24768,6 +25025,9 @@ ALTER TABLE ONLY agent_project_authorizations ALTER TABLE ONLY alert_management_alert_assignees ADD CONSTRAINT alert_management_alert_assignees_pkey PRIMARY KEY (id); +ALTER TABLE ONLY alert_management_alert_metric_images + ADD CONSTRAINT alert_management_alert_metric_images_pkey PRIMARY KEY (id); + ALTER TABLE ONLY alert_management_alert_user_mentions ADD CONSTRAINT alert_management_alert_user_mentions_pkey PRIMARY KEY (id); @@ -24780,6 +25040,9 @@ ALTER TABLE ONLY alert_management_http_integrations ALTER TABLE ONLY allowed_email_domains ADD CONSTRAINT allowed_email_domains_pkey PRIMARY KEY (id); +ALTER TABLE ONLY analytics_cycle_analytics_aggregations + ADD CONSTRAINT analytics_cycle_analytics_aggregations_pkey PRIMARY KEY (group_id); + ALTER TABLE ONLY analytics_cycle_analytics_group_stages ADD CONSTRAINT analytics_cycle_analytics_group_stages_pkey PRIMARY KEY (id); @@ -24954,9 +25217,6 @@ ALTER TABLE ONLY chat_teams ALTER TABLE vulnerability_scanners ADD CONSTRAINT check_37608c9db5 CHECK ((char_length(vendor) <= 255)) NOT VALID; -ALTER TABLE security_findings - ADD CONSTRAINT check_6c2851a8c9 CHECK ((uuid IS NOT NULL)) NOT VALID; - ALTER TABLE sprints ADD CONSTRAINT check_ccd8a1eae0 CHECK ((start_date IS NOT NULL)) NOT VALID; @@ -25083,6 +25343,9 @@ ALTER TABLE ONLY ci_runners ALTER TABLE ONLY ci_running_builds ADD CONSTRAINT ci_running_builds_pkey PRIMARY KEY (id); +ALTER TABLE ONLY ci_secure_files + ADD CONSTRAINT ci_secure_files_pkey PRIMARY KEY (id); + ALTER TABLE ONLY ci_sources_pipelines ADD CONSTRAINT ci_sources_pipelines_pkey PRIMARY KEY (id); @@ -25455,6 +25718,9 @@ ALTER TABLE ONLY gpg_signatures ALTER TABLE ONLY grafana_integrations ADD CONSTRAINT grafana_integrations_pkey PRIMARY KEY (id); +ALTER TABLE ONLY group_crm_settings + ADD CONSTRAINT group_crm_settings_pkey PRIMARY KEY (group_id); + ALTER TABLE ONLY group_custom_attributes ADD CONSTRAINT group_custom_attributes_pkey PRIMARY KEY (id); @@ -25470,6 +25736,9 @@ ALTER TABLE ONLY group_deploy_keys ALTER TABLE ONLY group_deploy_tokens ADD CONSTRAINT group_deploy_tokens_pkey PRIMARY KEY (id); +ALTER TABLE ONLY group_features + ADD CONSTRAINT group_features_pkey PRIMARY KEY (group_id); + ALTER TABLE ONLY group_group_links ADD CONSTRAINT group_group_links_pkey PRIMARY KEY (id); @@ -25890,9 +26159,6 @@ ALTER TABLE ONLY pages_domain_acme_orders ALTER TABLE ONLY pages_domains ADD CONSTRAINT pages_domains_pkey PRIMARY KEY (id); -ALTER TABLE ONLY partitioned_foreign_keys - ADD CONSTRAINT partitioned_foreign_keys_pkey PRIMARY KEY (id); - ALTER TABLE ONLY path_locks ADD CONSTRAINT path_locks_pkey PRIMARY KEY (id); @@ -25935,6 +26201,9 @@ ALTER TABLE ONLY project_authorizations ALTER TABLE ONLY project_auto_devops ADD CONSTRAINT project_auto_devops_pkey PRIMARY KEY (id); +ALTER TABLE ONLY project_build_artifacts_size_refreshes + ADD CONSTRAINT project_build_artifacts_size_refreshes_pkey PRIMARY KEY (id); + ALTER TABLE ONLY project_ci_cd_settings ADD CONSTRAINT project_ci_cd_settings_pkey PRIMARY KEY (id); @@ -26034,6 +26303,9 @@ ALTER TABLE ONLY protected_branch_unprotect_access_levels ALTER TABLE ONLY protected_branches ADD CONSTRAINT protected_branches_pkey PRIMARY KEY (id); +ALTER TABLE ONLY protected_environment_approval_rules + ADD CONSTRAINT protected_environment_approval_rules_pkey PRIMARY KEY (id); + ALTER TABLE ONLY protected_environment_deploy_access_levels ADD CONSTRAINT protected_environment_deploy_access_levels_pkey PRIMARY KEY (id); @@ -26058,9 +26330,15 @@ ALTER TABLE ONLY raw_usage_data ALTER TABLE ONLY redirect_routes ADD CONSTRAINT redirect_routes_pkey PRIMARY KEY (id); +ALTER TABLE ONLY related_epic_links + ADD CONSTRAINT related_epic_links_pkey PRIMARY KEY (id); + ALTER TABLE ONLY release_links ADD CONSTRAINT release_links_pkey PRIMARY KEY (id); +ALTER TABLE releases + ADD CONSTRAINT releases_not_null_tag CHECK ((tag IS NOT NULL)) NOT VALID; + ALTER TABLE ONLY releases ADD CONSTRAINT releases_pkey PRIMARY KEY (id); @@ -26106,6 +26384,9 @@ ALTER TABLE ONLY saml_group_links ALTER TABLE ONLY saml_providers ADD CONSTRAINT saml_providers_pkey PRIMARY KEY (id); +ALTER TABLE ONLY saved_replies + ADD CONSTRAINT saved_replies_pkey PRIMARY KEY (id); + ALTER TABLE ONLY scim_identities ADD CONSTRAINT scim_identities_pkey PRIMARY KEY (id); @@ -26124,6 +26405,12 @@ ALTER TABLE ONLY security_orchestration_policy_rule_schedules ALTER TABLE ONLY security_scans ADD CONSTRAINT security_scans_pkey PRIMARY KEY (id); +ALTER TABLE ONLY security_training_providers + ADD CONSTRAINT security_training_providers_pkey PRIMARY KEY (id); + +ALTER TABLE ONLY security_trainings + ADD CONSTRAINT security_trainings_pkey PRIMARY KEY (id); + ALTER TABLE ONLY self_managed_prometheus_alert_events ADD CONSTRAINT self_managed_prometheus_alert_events_pkey PRIMARY KEY (id); @@ -26307,24 +26594,6 @@ 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_assets - ADD CONSTRAINT vulnerability_finding_evidence_assets_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); - -ALTER TABLE ONLY vulnerability_finding_evidence_responses - ADD CONSTRAINT vulnerability_finding_evidence_responses_pkey PRIMARY KEY (id); - -ALTER TABLE ONLY vulnerability_finding_evidence_sources - ADD CONSTRAINT vulnerability_finding_evidence_sources_pkey PRIMARY KEY (id); - -ALTER TABLE ONLY vulnerability_finding_evidence_supporting_messages - ADD CONSTRAINT vulnerability_finding_evidence_supporting_messages_pkey PRIMARY KEY (id); - ALTER TABLE ONLY vulnerability_finding_evidences ADD CONSTRAINT vulnerability_finding_evidences_pkey PRIMARY KEY (id); @@ -26565,6 +26834,10 @@ CREATE INDEX incident_management_pending_issue_escalations_202_issue_id_idx8 ON CREATE INDEX incident_management_pending_issue_escalations_202_issue_id_idx9 ON gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202309 USING btree (issue_id); +CREATE INDEX index_loose_foreign_keys_deleted_records_for_partitioned_query ON ONLY loose_foreign_keys_deleted_records USING btree (partition, fully_qualified_table_name, consume_after, id) WHERE (status = 1); + +CREATE INDEX index_01e3390fac ON gitlab_partitions_dynamic.loose_foreign_keys_deleted_records_1 USING btree (partition, fully_qualified_table_name, consume_after, id) WHERE (status = 1); + CREATE INDEX index_web_hook_logs_part_on_web_hook_id ON ONLY web_hook_logs USING btree (web_hook_id); CREATE INDEX index_1554dc6f11 ON gitlab_partitions_dynamic.web_hook_logs_202301 USING btree (web_hook_id); @@ -26643,10 +26916,6 @@ CREATE INDEX index_merge_request_stage_events_project_duration ON ONLY analytics CREATE INDEX index_006f943df6 ON gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_16 USING btree (stage_event_hash_id, project_id, end_event_timestamp, merge_request_id, start_event_timestamp) WHERE (end_event_timestamp IS NOT NULL); -CREATE INDEX index_loose_foreign_keys_deleted_records_for_partitioned_query ON ONLY loose_foreign_keys_deleted_records USING btree (partition, fully_qualified_table_name, consume_after, id) WHERE (status = 1); - -CREATE INDEX index_01e3390fac ON gitlab_partitions_static.loose_foreign_keys_deleted_records_1 USING btree (partition, fully_qualified_table_name, consume_after, id) WHERE (status = 1); - CREATE INDEX index_02749b504c ON gitlab_partitions_static.analytics_cycle_analytics_merge_request_stage_events_11 USING btree (stage_event_hash_id, project_id, end_event_timestamp, merge_request_id, start_event_timestamp) WHERE (end_event_timestamp IS NOT NULL); CREATE INDEX index_merge_request_stage_events_group_duration ON ONLY analytics_cycle_analytics_merge_request_stage_events USING btree (stage_event_hash_id, group_id, end_event_timestamp, merge_request_id, start_event_timestamp) WHERE (end_event_timestamp IS NOT NULL); @@ -27571,6 +27840,12 @@ CREATE INDEX approval_mr_rule_index_merge_request_id ON approval_merge_request_r CREATE UNIQUE INDEX bulk_import_trackers_uniq_relation_by_entity ON bulk_import_trackers USING btree (bulk_import_entity_id, relation); +CREATE INDEX ca_aggregations_last_consistency_check_updated_at ON analytics_cycle_analytics_aggregations USING btree (last_consistency_check_updated_at NULLS FIRST) WHERE (enabled IS TRUE); + +CREATE INDEX ca_aggregations_last_full_run_at ON analytics_cycle_analytics_aggregations USING btree (last_full_run_at NULLS FIRST) WHERE (enabled IS TRUE); + +CREATE INDEX ca_aggregations_last_incremental_run_at ON analytics_cycle_analytics_aggregations USING btree (last_incremental_run_at NULLS FIRST) WHERE (enabled IS TRUE); + CREATE INDEX cadence_create_iterations_automation ON iterations_cadences USING btree (automatic, duration_in_weeks, date((COALESCE(last_run_date, '1970-01-01'::date) + ((duration_in_weeks)::double precision * '7 days'::interval)))) WHERE (duration_in_weeks IS NOT NULL); CREATE INDEX ci_builds_gitlab_monitor_metrics ON ci_builds USING btree (status, created_at, project_id) WHERE ((type)::text = 'Ci::Build'::text); @@ -27595,25 +27870,11 @@ 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_assets_on_finding_evidence_id ON vulnerability_finding_evidence_assets USING btree (vulnerability_finding_evidence_id); - -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_requests_on_supporting_evidence_id ON vulnerability_finding_evidence_requests USING btree (vulnerability_finding_evidence_supporting_message_id); - -CREATE INDEX finding_evidence_responses_on_finding_evidences_id ON vulnerability_finding_evidence_responses USING btree (vulnerability_finding_evidence_id); - -CREATE INDEX finding_evidence_responses_on_supporting_evidence_id ON vulnerability_finding_evidence_responses USING btree (vulnerability_finding_evidence_supporting_message_id); - -CREATE INDEX finding_evidence_sources_on_finding_evidence_id ON vulnerability_finding_evidence_sources USING btree (vulnerability_finding_evidence_id); +CREATE UNIQUE INDEX finding_evidences_on_unique_vulnerability_occurrence_id ON vulnerability_finding_evidences USING btree (vulnerability_occurrence_id); -CREATE INDEX finding_evidence_supporting_messages_on_finding_evidence_id ON vulnerability_finding_evidence_supporting_messages USING btree (vulnerability_finding_evidence_id); +CREATE UNIQUE INDEX finding_link_name_url_idx ON vulnerability_finding_links USING btree (vulnerability_occurrence_id, name, url); -CREATE UNIQUE INDEX finding_evidences_on_unique_vulnerability_occurrence_id ON vulnerability_finding_evidences USING btree (vulnerability_occurrence_id); +CREATE UNIQUE INDEX finding_link_url_idx ON vulnerability_finding_links USING btree (vulnerability_occurrence_id, url) WHERE (name IS NULL); CREATE INDEX finding_links_on_vulnerability_occurrence_id ON vulnerability_finding_links USING btree (vulnerability_occurrence_id); @@ -27625,6 +27886,8 @@ CREATE INDEX idx_analytics_devops_adoption_snapshots_finalized ON analytics_devo CREATE INDEX idx_award_emoji_on_user_emoji_name_awardable_type_awardable_id ON award_emoji USING btree (user_id, name, awardable_type, awardable_id); +CREATE INDEX idx_build_artifacts_size_refreshes_state_updated_at ON project_build_artifacts_size_refreshes USING btree (state, updated_at); + CREATE INDEX idx_ci_pipelines_artifacts_locked ON ci_pipelines USING btree (ci_ref_id, id) WHERE (locked = 1); CREATE INDEX idx_container_exp_policies_on_project_id_next_run_at ON container_expiration_policies USING btree (project_id, next_run_at) WHERE (enabled = true); @@ -27633,6 +27896,12 @@ CREATE INDEX idx_container_exp_policies_on_project_id_next_run_at_enabled ON con CREATE INDEX idx_container_repos_on_exp_cleanup_status_project_id_start_date ON container_repositories USING btree (expiration_policy_cleanup_status, project_id, expiration_policy_started_at); +CREATE INDEX idx_container_repos_on_import_started_at_when_importing ON container_repositories USING btree (migration_import_started_at) WHERE (migration_state = 'importing'::text); + +CREATE INDEX idx_container_repos_on_pre_import_done_at_when_pre_import_done ON container_repositories USING btree (migration_pre_import_done_at) WHERE (migration_state = 'pre_import_done'::text); + +CREATE INDEX idx_container_repos_on_pre_import_started_at_when_pre_importing ON container_repositories USING btree (migration_pre_import_started_at) WHERE (migration_state = 'pre_importing'::text); + 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); @@ -27701,12 +27970,16 @@ CREATE UNIQUE INDEX idx_on_external_status_checks_project_id_external_url ON ext CREATE UNIQUE INDEX idx_on_external_status_checks_project_id_name ON external_status_checks USING btree (project_id, name); -CREATE INDEX idx_packages_build_infos_on_package_id ON packages_build_infos USING btree (package_id); - CREATE INDEX idx_packages_debian_group_component_files_on_architecture_id ON packages_debian_group_component_files USING btree (architecture_id); CREATE INDEX idx_packages_debian_project_component_files_on_architecture_id ON packages_debian_project_component_files USING btree (architecture_id); +CREATE UNIQUE INDEX idx_packages_on_project_id_name_version_unique_when_generic ON packages_packages USING btree (project_id, name, version) WHERE ((package_type = 7) AND (status <> 4)); + +CREATE UNIQUE INDEX idx_packages_on_project_id_name_version_unique_when_golang ON packages_packages USING btree (project_id, name, version) WHERE ((package_type = 8) AND (status <> 4)); + +CREATE UNIQUE INDEX idx_packages_on_project_id_name_version_unique_when_helm ON packages_packages USING btree (project_id, name, version) WHERE ((package_type = 11) AND (status <> 4)); + CREATE INDEX idx_packages_packages_on_project_id_name_version_package_type ON packages_packages USING btree (project_id, name, version, package_type); CREATE INDEX idx_pkgs_debian_group_distribution_keys_on_distribution_id ON packages_debian_group_distribution_keys USING btree (distribution_id); @@ -27723,6 +27996,12 @@ CREATE UNIQUE INDEX idx_project_id_payload_key_self_managed_prometheus_alert_eve CREATE INDEX idx_project_repository_check_partial ON projects USING btree (repository_storage, created_at) WHERE (last_repository_check_at IS NULL); +CREATE INDEX idx_projects_api_created_at_id_for_archived ON projects USING btree (created_at, id) WHERE ((archived = true) AND (pending_delete = false) AND (hidden = false)); + +CREATE INDEX idx_projects_api_created_at_id_for_archived_vis20 ON projects USING btree (created_at, id) WHERE ((archived = true) AND (visibility_level = 20) AND (pending_delete = false) AND (hidden = false)); + +CREATE INDEX idx_projects_api_created_at_id_for_vis10 ON projects USING btree (created_at, id) WHERE ((visibility_level = 10) AND (pending_delete = false) AND (hidden = false)); + CREATE INDEX idx_projects_id_created_at_disable_overriding_approvers_false ON projects USING btree (id, created_at) WHERE ((disable_overriding_approvers_per_merge_request = false) OR (disable_overriding_approvers_per_merge_request IS NULL)); CREATE INDEX idx_projects_id_created_at_disable_overriding_approvers_true ON projects USING btree (id, created_at) WHERE (disable_overriding_approvers_per_merge_request = true); @@ -27747,6 +28026,8 @@ 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 INDEX idx_user_details_on_provisioned_by_group_id_user_id ON user_details USING btree (provisioned_by_group_id, user_id); + CREATE UNIQUE INDEX idx_vuln_signatures_on_occurrences_id_and_signature_sha ON vulnerability_finding_signatures USING btree (finding_id, signature_sha); CREATE UNIQUE INDEX idx_vuln_signatures_uniqueness_signature_sha ON vulnerability_finding_signatures USING btree (finding_id, algorithm_type, signature_sha); @@ -27785,6 +28066,8 @@ CREATE INDEX index_alert_assignees_on_alert_id ON alert_management_alert_assigne CREATE UNIQUE INDEX index_alert_assignees_on_user_id_and_alert_id ON alert_management_alert_assignees USING btree (user_id, alert_id); +CREATE INDEX index_alert_management_alert_metric_images_on_alert_id ON alert_management_alert_metric_images USING btree (alert_id); + CREATE INDEX index_alert_management_alerts_on_domain ON alert_management_alerts USING btree (domain); CREATE INDEX index_alert_management_alerts_on_environment_id ON alert_management_alerts USING btree (environment_id) WHERE (environment_id IS NOT NULL); @@ -27885,7 +28168,9 @@ CREATE UNIQUE INDEX index_approval_rule_name_for_code_owners_rule_type ON approv CREATE UNIQUE INDEX index_approval_rule_name_for_sectional_code_owners_rule_type ON approval_merge_request_rules USING btree (merge_request_id, name, section) WHERE (rule_type = 2); -CREATE INDEX index_approval_rules_code_owners_rule_type ON approval_merge_request_rules USING btree (merge_request_id, rule_type) WHERE (rule_type = 2); +CREATE INDEX index_approval_rule_on_protected_environment_id ON protected_environment_approval_rules USING btree (protected_environment_id); + +CREATE INDEX index_approval_rules_code_owners_rule_type ON approval_merge_request_rules USING btree (merge_request_id) WHERE (rule_type = 2); CREATE INDEX index_approvals_on_merge_request_id ON approvals USING btree (merge_request_id); @@ -27903,6 +28188,8 @@ CREATE INDEX index_approvers_on_user_id ON approvers USING btree (user_id); CREATE UNIQUE INDEX index_atlassian_identities_on_extern_uid ON atlassian_identities USING btree (extern_uid); +CREATE UNIQUE INDEX index_audit_events_external_audit_on_verification_token ON audit_events_external_audit_event_destinations USING btree (verification_token); + 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); @@ -28125,6 +28412,10 @@ CREATE INDEX index_ci_job_artifacts_on_file_store ON ci_job_artifacts USING btre CREATE INDEX index_ci_job_artifacts_on_file_type_for_devops_adoption ON ci_job_artifacts USING btree (file_type, project_id, created_at) WHERE (file_type = ANY (ARRAY[5, 6, 8, 23])); +CREATE INDEX index_ci_job_artifacts_on_id_project_id_and_created_at ON ci_job_artifacts USING btree (project_id, created_at, id); + +CREATE INDEX index_ci_job_artifacts_on_id_project_id_and_file_type ON ci_job_artifacts USING btree (project_id, file_type, id); + CREATE UNIQUE INDEX index_ci_job_artifacts_on_job_id_and_file_type ON ci_job_artifacts USING btree (job_id, file_type); CREATE INDEX index_ci_job_artifacts_on_project_id ON ci_job_artifacts USING btree (project_id); @@ -28231,6 +28522,8 @@ CREATE INDEX index_ci_pipelines_on_user_id_and_created_at_and_source ON ci_pipel CREATE INDEX index_ci_pipelines_on_user_id_and_id_and_cancelable_status ON ci_pipelines USING btree (user_id, id) WHERE ((status)::text = ANY (ARRAY[('running'::character varying)::text, ('waiting_for_resource'::character varying)::text, ('preparing'::character varying)::text, ('pending'::character varying)::text, ('created'::character varying)::text, ('scheduled'::character varying)::text])); +CREATE INDEX index_ci_pipelines_on_user_id_and_id_desc_and_user_not_verified ON ci_pipelines USING btree (user_id, id DESC) WHERE (failure_reason = 3); + CREATE INDEX index_ci_project_mirrors_on_namespace_id ON ci_project_mirrors USING btree (namespace_id); CREATE UNIQUE INDEX index_ci_project_mirrors_on_project_id ON ci_project_mirrors USING btree (project_id); @@ -28251,14 +28544,18 @@ CREATE UNIQUE INDEX index_ci_runner_namespaces_on_runner_id_and_namespace_id ON CREATE INDEX index_ci_runner_projects_on_project_id ON ci_runner_projects USING btree (project_id); -CREATE INDEX index_ci_runner_projects_on_runner_id ON ci_runner_projects USING btree (runner_id); +CREATE INDEX index_ci_runners_on_active ON ci_runners USING btree (active, id); CREATE INDEX index_ci_runners_on_contacted_at_and_id_desc ON ci_runners USING btree (contacted_at, id DESC); +CREATE INDEX index_ci_runners_on_contacted_at_and_id_where_inactive ON ci_runners USING btree (contacted_at DESC, id DESC) WHERE (active = false); + CREATE INDEX index_ci_runners_on_contacted_at_desc_and_id_desc ON ci_runners USING btree (contacted_at DESC, id DESC); CREATE INDEX index_ci_runners_on_created_at_and_id_desc ON ci_runners USING btree (created_at, id DESC); +CREATE INDEX index_ci_runners_on_created_at_and_id_where_inactive ON ci_runners USING btree (created_at DESC, id DESC) WHERE (active = false); + CREATE INDEX index_ci_runners_on_created_at_desc_and_id_desc ON ci_runners USING btree (created_at DESC, id DESC); CREATE INDEX index_ci_runners_on_description_trigram ON ci_runners USING gin (description gin_trgm_ops); @@ -28271,12 +28568,18 @@ CREATE INDEX index_ci_runners_on_token ON ci_runners USING btree (token); CREATE INDEX index_ci_runners_on_token_encrypted ON ci_runners USING btree (token_encrypted); +CREATE INDEX index_ci_runners_on_token_expires_at_and_id_desc ON ci_runners USING btree (token_expires_at, id DESC); + +CREATE INDEX index_ci_runners_on_token_expires_at_desc_and_id_desc ON ci_runners USING btree (token_expires_at DESC, id DESC); + CREATE UNIQUE INDEX index_ci_running_builds_on_build_id ON ci_running_builds USING btree (build_id); CREATE INDEX index_ci_running_builds_on_project_id ON ci_running_builds USING btree (project_id); CREATE INDEX index_ci_running_builds_on_runner_id ON ci_running_builds USING btree (runner_id); +CREATE INDEX index_ci_secure_files_on_project_id ON ci_secure_files USING btree (project_id); + CREATE INDEX index_ci_sources_pipelines_on_pipeline_id ON ci_sources_pipelines USING btree (pipeline_id); CREATE INDEX index_ci_sources_pipelines_on_project_id ON ci_sources_pipelines USING btree (project_id); @@ -28321,7 +28624,7 @@ CREATE INDEX index_ci_variables_on_key ON ci_variables USING btree (key); CREATE UNIQUE INDEX index_ci_variables_on_project_id_and_key_and_environment_scope ON ci_variables USING btree (project_id, key, environment_scope); -CREATE INDEX index_cluster_agent_tokens_on_agent_id_and_last_used_at ON cluster_agent_tokens USING btree (agent_id, last_used_at DESC NULLS LAST); +CREATE INDEX index_cluster_agent_tokens_on_agent_id_status_last_used_at ON cluster_agent_tokens USING btree (agent_id, status, last_used_at DESC NULLS LAST); CREATE INDEX index_cluster_agent_tokens_on_created_by_user_id ON cluster_agent_tokens USING btree (created_by_user_id); @@ -28377,8 +28680,6 @@ CREATE INDEX index_clusters_integration_elasticstack_enabled ON clusters_integra CREATE INDEX index_clusters_integration_prometheus_enabled ON clusters_integration_prometheus USING btree (enabled, created_at, cluster_id); -CREATE INDEX index_clusters_kubernetes_namespaces_on_cluster_id ON clusters_kubernetes_namespaces USING btree (cluster_id); - CREATE INDEX index_clusters_kubernetes_namespaces_on_cluster_project_id ON clusters_kubernetes_namespaces USING btree (cluster_project_id); CREATE INDEX index_clusters_kubernetes_namespaces_on_environment_id ON clusters_kubernetes_namespaces USING btree (environment_id); @@ -28401,6 +28702,10 @@ CREATE INDEX index_composer_cache_files_where_namespace_id_is_null ON packages_c CREATE INDEX index_container_expiration_policies_on_next_run_at_and_enabled ON container_expiration_policies USING btree (next_run_at, enabled); +CREATE INDEX index_container_repositories_on_greatest_done_at ON container_repositories USING btree (GREATEST(migration_pre_import_done_at, migration_import_done_at, migration_aborted_at)) WHERE (migration_state = ANY (ARRAY['import_done'::text, 'pre_import_done'::text, 'import_aborted'::text])); + +CREATE INDEX index_container_repositories_on_migration_state_import_done_at ON container_repositories USING btree (migration_state, migration_import_done_at); + CREATE INDEX index_container_repositories_on_project_id ON container_repositories USING btree (project_id); CREATE INDEX index_container_repositories_on_project_id_and_id ON container_repositories USING btree (project_id, id); @@ -28627,8 +28932,6 @@ CREATE UNIQUE INDEX index_epic_board_list_preferences_on_user_and_list ON boards CREATE UNIQUE INDEX index_epic_board_recent_visits_on_user_group_and_board ON boards_epic_board_recent_visits USING btree (user_id, group_id, epic_board_id); -CREATE INDEX index_epic_issues_on_epic_id ON epic_issues USING btree (epic_id); - CREATE INDEX index_epic_issues_on_epic_id_and_issue_id ON epic_issues USING btree (epic_id, issue_id); CREATE UNIQUE INDEX index_epic_issues_on_issue_id ON epic_issues USING btree (issue_id); @@ -28661,8 +28964,6 @@ CREATE INDEX index_epics_on_iid ON epics USING btree (iid); CREATE INDEX index_epics_on_last_edited_by_id ON epics USING btree (last_edited_by_id); -CREATE INDEX index_epics_on_lock_version ON epics USING btree (lock_version) WHERE (lock_version IS NULL); - CREATE INDEX index_epics_on_parent_id ON epics USING btree (parent_id); CREATE INDEX index_epics_on_start_date ON epics USING btree (start_date); @@ -28693,13 +28994,15 @@ CREATE INDEX index_et_errors_on_project_id_and_status_first_seen_at_id_desc ON e CREATE INDEX index_et_errors_on_project_id_and_status_last_seen_at_id_desc ON error_tracking_errors USING btree (project_id, status, last_seen_at DESC, id DESC); +CREATE INDEX index_events_author_id_project_id_action_target_type_created_at ON events USING btree (author_id, project_id, action, target_type, created_at); + CREATE INDEX index_events_on_action ON events USING btree (action); CREATE INDEX index_events_on_author_id_and_created_at ON events USING btree (author_id, created_at); CREATE INDEX index_events_on_author_id_and_created_at_merge_requests ON events USING btree (author_id, created_at) WHERE ((target_type)::text = 'MergeRequest'::text); -CREATE INDEX index_events_on_author_id_and_project_id ON events USING btree (author_id, project_id); +CREATE INDEX index_events_on_author_id_and_id ON events USING btree (author_id, id); CREATE INDEX index_events_on_created_at_and_id ON events USING btree (created_at, id) WHERE (created_at > '2021-08-27 00:00:00+00'::timestamp with time zone); @@ -28853,6 +29156,8 @@ CREATE INDEX index_grafana_integrations_on_enabled ON grafana_integrations USING CREATE INDEX index_grafana_integrations_on_project_id ON grafana_integrations USING btree (project_id); +CREATE INDEX index_group_crm_settings_on_group_id ON group_crm_settings USING btree (group_id); + CREATE UNIQUE INDEX index_group_custom_attributes_on_group_id_and_key ON group_custom_attributes USING btree (group_id, key); CREATE INDEX index_group_custom_attributes_on_key_and_value ON group_custom_attributes USING btree (key, value); @@ -28961,21 +29266,21 @@ CREATE INDEX index_insights_on_project_id ON insights USING btree (project_id); CREATE INDEX index_integrations_on_inherit_from_id ON integrations USING btree (inherit_from_id); -CREATE INDEX index_integrations_on_project_and_type_where_inherit_null ON integrations USING btree (project_id, type) WHERE (inherit_from_id IS NULL); +CREATE INDEX index_integrations_on_project_and_type_new_where_inherit_null ON integrations USING btree (project_id, type_new) WHERE (inherit_from_id IS NULL); -CREATE UNIQUE INDEX index_integrations_on_project_id_and_type_unique ON integrations USING btree (project_id, type); +CREATE UNIQUE INDEX index_integrations_on_project_id_and_type_new_unique ON integrations USING btree (project_id, type_new); CREATE INDEX index_integrations_on_template ON integrations USING btree (template); -CREATE INDEX index_integrations_on_type ON integrations USING btree (type); +CREATE INDEX index_integrations_on_type_new ON integrations USING btree (type_new); -CREATE UNIQUE INDEX index_integrations_on_type_and_instance_partial ON integrations USING btree (type, instance) WHERE (instance = true); +CREATE INDEX index_integrations_on_type_new_and_instance_partial ON integrations USING btree (type_new, instance) WHERE (instance = true); -CREATE UNIQUE INDEX index_integrations_on_type_and_template_partial ON integrations USING btree (type, template) WHERE (template = true); +CREATE INDEX index_integrations_on_type_new_and_template_partial ON integrations USING btree (type_new, template) WHERE (template = true); -CREATE INDEX index_integrations_on_type_id_when_active_and_project_id_not_nu ON integrations USING btree (type, id) WHERE ((active = true) AND (project_id IS NOT NULL)); +CREATE INDEX index_integrations_on_type_new_id_when_active_and_has_project ON integrations USING btree (type_new, id) WHERE ((active = true) AND (project_id IS NOT NULL)); -CREATE UNIQUE INDEX index_integrations_on_unique_group_id_and_type ON integrations USING btree (group_id, type); +CREATE INDEX index_integrations_on_unique_group_id_and_type_new ON integrations USING btree (group_id, type_new); CREATE INDEX index_internal_ids_on_namespace_id ON internal_ids USING btree (namespace_id); @@ -29013,8 +29318,6 @@ CREATE UNIQUE INDEX index_issue_links_on_source_id_and_target_id ON issue_links CREATE INDEX index_issue_links_on_target_id ON issue_links USING btree (target_id); -CREATE INDEX index_issue_metrics_first_mentioned_in_commit ON issue_metrics USING btree (issue_id) WHERE (date_part('year'::text, first_mentioned_in_commit_at) > (2019)::double precision); - CREATE INDEX index_issue_metrics_on_issue_id_and_timestamps ON issue_metrics USING btree (issue_id, first_mentioned_in_commit_at, first_associated_with_milestone_at, first_added_to_board_at); CREATE INDEX index_issue_on_project_id_state_id_and_blocking_issues_count ON issues USING btree (project_id, state_id, blocking_issues_count); @@ -29035,12 +29338,12 @@ CREATE INDEX index_issues_on_description_trigram ON issues USING gin (descriptio CREATE INDEX index_issues_on_duplicated_to_id ON issues USING btree (duplicated_to_id) WHERE (duplicated_to_id IS NOT NULL); +CREATE INDEX index_issues_on_id_and_weight ON issues USING btree (id, weight); + CREATE INDEX index_issues_on_incident_issue_type ON issues USING btree (issue_type) WHERE (issue_type = 1); CREATE INDEX index_issues_on_last_edited_by_id ON issues USING btree (last_edited_by_id); -CREATE INDEX index_issues_on_lock_version ON issues USING btree (lock_version) WHERE (lock_version IS NULL); - CREATE INDEX index_issues_on_milestone_id ON issues USING btree (milestone_id); CREATE INDEX index_issues_on_moved_to_id ON issues USING btree (moved_to_id) WHERE (moved_to_id IS NOT NULL); @@ -29183,6 +29486,8 @@ CREATE INDEX index_members_on_invite_email ON members USING btree (invite_email) CREATE UNIQUE INDEX index_members_on_invite_token ON members USING btree (invite_token); +CREATE INDEX index_members_on_member_namespace_id ON members USING btree (member_namespace_id); + CREATE INDEX index_members_on_requested_at ON members USING btree (requested_at); CREATE INDEX index_members_on_source_id_and_source_type ON members USING btree (source_id, source_type); @@ -29205,8 +29510,6 @@ CREATE UNIQUE INDEX index_merge_request_cleanup_schedules_on_merge_request_id ON CREATE INDEX index_merge_request_cleanup_schedules_on_status ON merge_request_cleanup_schedules USING btree (status); -CREATE INDEX index_merge_request_context_commits_on_merge_request_id ON merge_request_context_commits USING btree (merge_request_id); - CREATE UNIQUE INDEX index_merge_request_diff_commit_users_on_name_and_email ON merge_request_diff_commit_users USING btree (name, email); CREATE INDEX index_merge_request_diff_commits_on_sha ON merge_request_diff_commits USING btree (sha); @@ -29271,8 +29574,6 @@ CREATE INDEX index_merge_requests_on_head_pipeline_id ON merge_requests USING bt CREATE INDEX index_merge_requests_on_latest_merge_request_diff_id ON merge_requests USING btree (latest_merge_request_diff_id); -CREATE INDEX index_merge_requests_on_lock_version ON merge_requests USING btree (lock_version) WHERE (lock_version IS NULL); - CREATE INDEX index_merge_requests_on_merge_user_id ON merge_requests USING btree (merge_user_id) WHERE (merge_user_id IS NOT NULL); CREATE INDEX index_merge_requests_on_milestone_id ON merge_requests USING btree (milestone_id); @@ -29303,8 +29604,6 @@ CREATE INDEX index_merge_requests_on_target_project_id_and_updated_at_and_id ON CREATE INDEX index_merge_requests_on_target_project_id_iid_jira_description ON merge_requests USING btree (target_project_id, iid) WHERE (description ~ '[A-Z][A-Z_0-9]+-\d+'::text); -CREATE INDEX index_merge_requests_on_title ON merge_requests USING btree (title); - CREATE INDEX index_merge_requests_on_title_trigram ON merge_requests USING gin (title gin_trgm_ops); CREATE INDEX index_merge_requests_on_tp_id_and_merge_commit_sha_and_id ON merge_requests USING btree (target_project_id, merge_commit_sha, id); @@ -29463,8 +29762,18 @@ CREATE INDEX index_on_identities_lower_extern_uid_and_provider ON identities USI CREATE UNIQUE INDEX index_on_instance_statistics_recorded_at_and_identifier ON analytics_usage_trends_measurements USING btree (identifier, recorded_at); +CREATE INDEX index_on_issues_closed_incidents_by_project_id_and_closed_at ON issues USING btree (project_id, closed_at) WHERE ((issue_type = 1) AND (state_id = 2)); + CREATE INDEX index_on_label_links_all_columns ON label_links USING btree (target_id, label_id, target_type); +CREATE INDEX index_on_merge_request_assignees_state ON merge_request_assignees USING btree (state) WHERE (state = 2); + +CREATE INDEX index_on_merge_request_assignees_updated_state_by_user_id ON merge_request_assignees USING btree (updated_state_by_user_id); + +CREATE INDEX index_on_merge_request_reviewers_state ON merge_request_reviewers USING btree (state) WHERE (state = 2); + +CREATE INDEX index_on_merge_request_reviewers_updated_state_by_user_id ON merge_request_reviewers USING btree (updated_state_by_user_id); + CREATE INDEX index_on_merge_requests_for_latest_diffs ON merge_requests USING btree (target_project_id) INCLUDE (id, latest_merge_request_diff_id); COMMENT ON INDEX index_on_merge_requests_for_latest_diffs IS 'Index used to efficiently obtain the oldest merge request for a commit SHA'; @@ -29481,6 +29790,8 @@ CREATE UNIQUE INDEX index_on_project_id_escalation_policy_name_unique ON inciden CREATE INDEX index_on_projects_lower_path ON projects USING btree (lower((path)::text)); +CREATE INDEX index_on_projects_path ON projects USING btree (path); + CREATE INDEX index_on_routes_lower_path ON routes USING btree (lower((path)::text)); CREATE INDEX index_on_users_lower_email ON users USING btree (lower((email)::text)); @@ -29523,6 +29834,8 @@ CREATE UNIQUE INDEX index_ops_strategies_user_lists_on_strategy_id_and_user_list CREATE INDEX index_packages_build_infos_on_pipeline_id ON packages_build_infos USING btree (pipeline_id); +CREATE INDEX index_packages_build_infos_package_id_pipeline_id ON packages_build_infos USING btree (package_id, pipeline_id); + CREATE UNIQUE INDEX index_packages_composer_cache_namespace_and_sha ON packages_composer_cache_files USING btree (namespace_id, file_sha256); CREATE UNIQUE INDEX index_packages_composer_metadata_on_package_id_and_target_sha ON packages_composer_metadata USING btree (package_id, target_sha); @@ -29563,12 +29876,6 @@ CREATE INDEX index_packages_maven_metadata_on_path ON packages_maven_metadata US CREATE INDEX index_packages_nuget_dl_metadata_on_dependency_link_id ON packages_nuget_dependency_link_metadata USING btree (dependency_link_id); -CREATE UNIQUE INDEX index_packages_on_project_id_name_version_unique_when_generic ON packages_packages USING btree (project_id, name, version) WHERE (package_type = 7); - -CREATE UNIQUE INDEX index_packages_on_project_id_name_version_unique_when_golang ON packages_packages USING btree (project_id, name, version) WHERE (package_type = 8); - -CREATE UNIQUE INDEX index_packages_on_project_id_name_version_unique_when_helm ON packages_packages USING btree (project_id, name, version) WHERE (package_type = 11); - CREATE INDEX index_packages_package_file_build_infos_on_package_file_id ON packages_package_file_build_infos USING btree (package_file_id); CREATE INDEX index_packages_package_file_build_infos_on_pipeline_id ON packages_package_file_build_infos USING btree (pipeline_id); @@ -29579,6 +29886,10 @@ CREATE INDEX index_packages_package_files_on_package_id_and_file_name ON package CREATE INDEX index_packages_package_files_on_package_id_id ON packages_package_files USING btree (package_id, id); +CREATE INDEX index_packages_package_files_on_package_id_status_and_id ON packages_package_files USING btree (package_id, status, id); + +CREATE INDEX index_packages_package_files_on_status ON packages_package_files USING btree (status); + CREATE INDEX index_packages_package_files_on_verification_state ON packages_package_files USING btree (verification_state); CREATE INDEX index_packages_packages_on_creator_id ON packages_packages USING btree (creator_id); @@ -29649,8 +29960,6 @@ CREATE UNIQUE INDEX index_partial_am_alerts_on_project_id_and_fingerprint ON ale CREATE INDEX index_partial_ci_builds_on_user_id_name_parser_features ON ci_builds USING btree (user_id, name) WHERE (((type)::text = 'Ci::Build'::text) AND ((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('license_scanning'::character varying)::text, ('sast'::character varying)::text, ('coverage_fuzzing'::character varying)::text, ('secret_detection'::character varying)::text]))); -CREATE UNIQUE INDEX index_partitioned_foreign_keys_unique_index ON partitioned_foreign_keys USING btree (to_table, from_table, from_column); - CREATE INDEX index_pat_on_user_id_and_expires_at ON personal_access_tokens USING btree (user_id, expires_at); CREATE INDEX index_path_locks_on_path ON path_locks USING btree (path); @@ -29689,6 +29998,8 @@ CREATE INDEX index_project_aliases_on_project_id ON project_aliases USING btree CREATE UNIQUE INDEX index_project_auto_devops_on_project_id ON project_auto_devops USING btree (project_id); +CREATE UNIQUE INDEX index_project_build_artifacts_size_refreshes_on_project_id ON project_build_artifacts_size_refreshes USING btree (project_id); + CREATE UNIQUE INDEX index_project_ci_cd_settings_on_project_id ON project_ci_cd_settings USING btree (project_id); CREATE UNIQUE INDEX index_project_ci_feature_usages_unique_columns ON project_ci_feature_usages USING btree (project_id, feature, default_branch); @@ -29789,12 +30100,6 @@ CREATE INDEX index_projects_aimed_for_deletion ON projects USING btree (marked_f CREATE INDEX index_projects_api_created_at_id_desc ON projects USING btree (created_at, id DESC); -CREATE INDEX index_projects_api_created_at_id_for_archived ON projects USING btree (created_at, id) WHERE ((archived = true) AND (pending_delete = false)); - -CREATE INDEX index_projects_api_created_at_id_for_archived_vis20 ON projects USING btree (created_at, id) WHERE ((archived = true) AND (visibility_level = 20) AND (pending_delete = false)); - -CREATE INDEX index_projects_api_created_at_id_for_vis10 ON projects USING btree (created_at, id) WHERE ((visibility_level = 10) AND (pending_delete = false)); - CREATE INDEX index_projects_api_last_activity_at_id_desc ON projects USING btree (last_activity_at, id DESC); CREATE INDEX index_projects_api_name_id_desc ON projects USING btree (name, id DESC); @@ -29813,6 +30118,8 @@ CREATE INDEX index_projects_api_vis20_path ON projects USING btree (path, id) WH CREATE INDEX index_projects_api_vis20_updated_at ON projects USING btree (updated_at, id) WHERE (visibility_level = 20); +CREATE INDEX index_projects_not_aimed_for_deletion ON projects USING btree (id) WHERE (marked_for_deletion_at IS NULL); + CREATE INDEX index_projects_on_created_at_and_id ON projects USING btree (created_at, id); CREATE INDEX index_projects_on_creator_id_and_created_at_and_id ON projects USING btree (creator_id, created_at, id); @@ -29917,6 +30224,10 @@ CREATE INDEX index_protected_branch_unprotect_access_levels_on_user_id ON protec CREATE INDEX index_protected_branches_on_project_id ON protected_branches USING btree (project_id); +CREATE INDEX index_protected_environment_approval_rules_on_group_id ON protected_environment_approval_rules USING btree (group_id); + +CREATE INDEX index_protected_environment_approval_rules_on_user_id ON protected_environment_approval_rules USING btree (user_id); + CREATE INDEX index_protected_environment_deploy_access ON protected_environment_deploy_access_levels USING btree (protected_environment_id); CREATE INDEX index_protected_environment_deploy_access_levels_on_group_id ON protected_environment_deploy_access_levels USING btree (group_id); @@ -29951,13 +30262,21 @@ CREATE UNIQUE INDEX index_redirect_routes_on_path_unique_text_pattern_ops ON red CREATE INDEX index_redirect_routes_on_source_type_and_source_id ON redirect_routes USING btree (source_type, source_id); +CREATE INDEX index_related_epic_links_on_source_id ON related_epic_links USING btree (source_id); + +CREATE UNIQUE INDEX index_related_epic_links_on_source_id_and_target_id ON related_epic_links USING btree (source_id, target_id); + +CREATE INDEX index_related_epic_links_on_target_id ON related_epic_links USING btree (target_id); + CREATE UNIQUE INDEX index_release_links_on_release_id_and_name ON release_links USING btree (release_id, name); CREATE UNIQUE INDEX index_release_links_on_release_id_and_url ON release_links USING btree (release_id, url); CREATE INDEX index_releases_on_author_id_id_created_at ON releases USING btree (author_id, id, created_at); -CREATE INDEX index_releases_on_project_id_and_tag ON releases USING btree (project_id, tag); +CREATE INDEX index_releases_on_project_id_and_released_at_and_id ON releases USING btree (project_id, released_at, id); + +CREATE UNIQUE INDEX index_releases_on_project_tag_unique ON releases USING btree (project_id, tag); CREATE INDEX index_releases_on_released_at ON releases USING btree (released_at); @@ -30047,6 +30366,8 @@ CREATE INDEX index_reviews_on_project_id ON reviews USING btree (project_id); CREATE INDEX index_route_on_name_trigram ON routes USING gin (name gin_trgm_ops); +CREATE UNIQUE INDEX index_routes_on_namespace_id ON routes USING btree (namespace_id); + CREATE UNIQUE INDEX index_routes_on_path ON routes USING btree (path); CREATE INDEX index_routes_on_path_text_pattern_ops ON routes USING btree (path varchar_pattern_ops); @@ -30059,6 +30380,8 @@ CREATE UNIQUE INDEX index_saml_group_links_on_group_id_and_saml_group_name ON sa CREATE INDEX index_saml_providers_on_group_id ON saml_providers USING btree (group_id); +CREATE UNIQUE INDEX index_saved_replies_on_name_text_pattern_ops ON saved_replies USING btree (user_id, name text_pattern_ops); + CREATE INDEX index_scim_identities_on_group_id ON scim_identities USING btree (group_id); CREATE UNIQUE INDEX index_scim_identities_on_lower_extern_uid_and_group_id ON scim_identities USING btree (lower((extern_uid)::text), group_id); @@ -30069,7 +30392,7 @@ CREATE UNIQUE INDEX index_scim_oauth_access_tokens_on_group_id_and_token_encrypt CREATE INDEX index_secure_ci_builds_on_user_id_name_created_at ON ci_builds USING btree (user_id, name, created_at) WHERE (((type)::text = 'Ci::Build'::text) AND ((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('license_scanning'::character varying)::text, ('sast'::character varying)::text, ('coverage_fuzzing'::character varying)::text, ('apifuzzer_fuzz'::character varying)::text, ('apifuzzer_fuzz_dnd'::character varying)::text, ('secret_detection'::character varying)::text]))); -CREATE INDEX index_security_ci_builds_on_name_and_id_parser_features ON ci_builds USING btree (name, id) WHERE (((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('sast'::character varying)::text, ('secret_detection'::character varying)::text, ('coverage_fuzzing'::character varying)::text, ('license_scanning'::character varying)::text])) AND ((type)::text = 'Ci::Build'::text)); +CREATE INDEX index_security_ci_builds_on_name_and_id_parser_features ON ci_builds USING btree (name, id) WHERE (((name)::text = ANY (ARRAY[('container_scanning'::character varying)::text, ('dast'::character varying)::text, ('dependency_scanning'::character varying)::text, ('license_management'::character varying)::text, ('sast'::character varying)::text, ('secret_detection'::character varying)::text, ('coverage_fuzzing'::character varying)::text, ('license_scanning'::character varying)::text, ('apifuzzer_fuzz'::character varying)::text, ('apifuzzer_fuzz_dnd'::character varying)::text])) AND ((type)::text = 'Ci::Build'::text)); CREATE INDEX index_security_findings_on_confidence ON security_findings USING btree (confidence); @@ -30077,7 +30400,7 @@ CREATE INDEX index_security_findings_on_project_fingerprint ON security_findings CREATE INDEX index_security_findings_on_scan_id_and_deduplicated ON security_findings USING btree (scan_id, deduplicated); -CREATE UNIQUE INDEX index_security_findings_on_scan_id_and_position ON security_findings USING btree (scan_id, "position"); +CREATE INDEX index_security_findings_on_scan_id_and_id ON security_findings USING btree (scan_id, id); CREATE INDEX index_security_findings_on_scanner_id ON security_findings USING btree (scanner_id); @@ -30093,6 +30416,14 @@ CREATE INDEX index_security_scans_on_pipeline_id ON security_scans USING btree ( CREATE INDEX index_security_scans_on_project_id ON security_scans USING btree (project_id); +CREATE UNIQUE INDEX index_security_training_providers_on_unique_name ON security_training_providers USING btree (name); + +CREATE INDEX index_security_trainings_on_project_id ON security_trainings USING btree (project_id); + +CREATE INDEX index_security_trainings_on_provider_id ON security_trainings USING btree (provider_id); + +CREATE UNIQUE INDEX index_security_trainings_on_unique_project_id ON security_trainings USING btree (project_id) WHERE (is_primary IS TRUE); + CREATE INDEX index_self_managed_prometheus_alert_events_on_environment_id ON self_managed_prometheus_alert_events USING btree (environment_id); CREATE INDEX index_sent_notifications_on_noteable_type_noteable_id ON sent_notifications USING btree (noteable_id) WHERE ((noteable_type)::text = 'Issue'::text); @@ -30155,6 +30486,8 @@ CREATE INDEX index_snippets_on_id_and_created_at ON snippets USING btree (id, cr CREATE INDEX index_snippets_on_id_and_type ON snippets USING btree (id, type); +CREATE INDEX index_snippets_on_project_id_and_title ON snippets USING btree (project_id, title); + CREATE INDEX index_snippets_on_project_id_and_visibility_level ON snippets USING btree (project_id, visibility_level); CREATE INDEX index_snippets_on_title_trigram ON snippets USING gin (title gin_trgm_ops); @@ -30171,8 +30504,6 @@ CREATE INDEX index_software_licenses_on_spdx_identifier ON software_licenses USI CREATE UNIQUE INDEX index_software_licenses_on_unique_name ON software_licenses USING btree (name); -CREATE UNIQUE INDEX index_sop_configs_on_project_id ON security_orchestration_policy_configurations USING btree (project_id); - CREATE INDEX index_sop_configurations_project_id_policy_project_id ON security_orchestration_policy_configurations USING btree (security_policy_management_project_id, project_id); CREATE INDEX index_sop_schedules_on_sop_configuration_id ON security_orchestration_policy_rule_schedules USING btree (security_orchestration_policy_configuration_id); @@ -30189,12 +30520,8 @@ CREATE INDEX index_sprints_on_due_date ON sprints USING btree (due_date); CREATE INDEX index_sprints_on_group_id ON sprints USING btree (group_id); -CREATE UNIQUE INDEX index_sprints_on_iterations_cadence_id_and_title ON sprints USING btree (iterations_cadence_id, title); - CREATE UNIQUE INDEX index_sprints_on_project_id_and_iid ON sprints USING btree (project_id, iid); -CREATE UNIQUE INDEX index_sprints_on_project_id_and_title ON sprints USING btree (project_id, title) WHERE (project_id IS NOT NULL); - CREATE INDEX index_sprints_on_title ON sprints USING btree (title); CREATE INDEX index_sprints_on_title_trigram ON sprints USING gin (title gin_trgm_ops); @@ -30215,8 +30542,6 @@ CREATE UNIQUE INDEX index_subscriptions_on_subscribable_and_user_id_and_project_ CREATE INDEX index_successful_deployments_on_cluster_id_and_environment_id ON deployments USING btree (cluster_id, environment_id) WHERE (status = 2); -CREATE INDEX index_suggestions_on_note_id ON suggestions USING btree (note_id); - CREATE UNIQUE INDEX index_suggestions_on_note_id_and_relative_order ON suggestions USING btree (note_id, relative_order); CREATE UNIQUE INDEX index_system_note_metadata_on_description_version_id ON system_note_metadata USING btree (description_version_id) WHERE (description_version_id IS NOT NULL); @@ -30279,7 +30604,7 @@ CREATE INDEX index_todos_on_group_id ON todos USING btree (group_id); CREATE INDEX index_todos_on_note_id ON todos USING btree (note_id); -CREATE INDEX index_todos_on_project_id ON todos USING btree (project_id); +CREATE INDEX index_todos_on_project_id_and_id ON todos USING btree (project_id, id); CREATE INDEX index_todos_on_project_id_and_user_id_and_id ON todos USING btree (project_id, user_id, id); @@ -30295,6 +30620,10 @@ CREATE UNIQUE INDEX index_token_with_ivs_on_hashed_plaintext_token ON token_with CREATE UNIQUE INDEX index_token_with_ivs_on_hashed_token ON token_with_ivs USING btree (hashed_token); +CREATE INDEX index_topics_non_private_projects_count ON topics USING btree (non_private_projects_count DESC, id); + +CREATE INDEX index_topics_on_lower_name ON topics USING btree (lower(name)); + CREATE UNIQUE INDEX index_topics_on_name ON topics USING btree (name); CREATE INDEX index_topics_on_name_trigram ON topics USING gin (name gin_trgm_ops); @@ -30309,6 +30638,8 @@ CREATE INDEX index_u2f_registrations_on_user_id ON u2f_registrations USING btree CREATE UNIQUE INDEX index_uniq_im_issuable_escalation_statuses_on_issue_id ON incident_management_issuable_escalation_statuses USING btree (issue_id); +CREATE UNIQUE INDEX index_unique_ci_runner_projects_on_runner_id_and_project_id ON ci_runner_projects USING btree (runner_id, project_id); + CREATE UNIQUE INDEX index_unique_issue_metrics_issue_id ON issue_metrics USING btree (issue_id); CREATE UNIQUE INDEX index_unique_project_authorizations_on_project_id_user_id ON project_authorizations USING btree (project_id, user_id); @@ -30361,8 +30692,6 @@ CREATE UNIQUE INDEX index_user_details_on_phone ON user_details USING btree (pho COMMENT ON INDEX index_user_details_on_phone IS 'JiHu-specific index'; -CREATE INDEX index_user_details_on_provisioned_by_group_id ON user_details USING btree (provisioned_by_group_id); - CREATE UNIQUE INDEX index_user_details_on_user_id ON user_details USING btree (user_id); CREATE INDEX index_user_group_callouts_on_group_id ON user_group_callouts USING btree (group_id); @@ -30443,6 +30772,8 @@ CREATE INDEX index_users_star_projects_on_project_id ON users_star_projects USIN CREATE UNIQUE INDEX index_users_star_projects_on_user_id_and_project_id ON users_star_projects USING btree (user_id, project_id); +CREATE INDEX index_users_with_static_object_token ON users USING btree (id) WHERE ((static_object_token IS NOT NULL) AND (static_object_token_encrypted IS NULL)); + CREATE UNIQUE INDEX index_vuln_historical_statistics_on_project_id_and_date ON vulnerability_historical_statistics USING btree (project_id, date); CREATE INDEX index_vuln_reads_on_project_id_state_severity_and_vuln_id ON vulnerability_reads USING btree (project_id, state, severity, vulnerability_id DESC); @@ -30461,6 +30792,10 @@ CREATE INDEX index_vulnerabilities_on_last_edited_by_id ON vulnerabilities USING CREATE INDEX index_vulnerabilities_on_milestone_id ON vulnerabilities USING btree (milestone_id); +CREATE INDEX index_vulnerabilities_on_project_id_and_id ON vulnerabilities USING btree (project_id, id); + +CREATE INDEX index_vulnerabilities_on_project_id_and_id_active_cis ON vulnerabilities USING btree (project_id, id) WHERE ((report_type = 7) AND (state = ANY (ARRAY[1, 4]))); + CREATE INDEX index_vulnerabilities_on_project_id_and_state_and_severity ON vulnerabilities USING btree (project_id, state, severity); CREATE INDEX index_vulnerabilities_on_resolved_by_id ON vulnerabilities USING btree (resolved_by_id); @@ -30525,10 +30860,12 @@ CREATE INDEX index_vulnerability_occurrences_deduplication ON vulnerability_occu CREATE INDEX index_vulnerability_occurrences_for_issue_links_migration ON vulnerability_occurrences USING btree (project_id, report_type, encode(project_fingerprint, 'hex'::text)); -CREATE INDEX index_vulnerability_occurrences_on_location_cluster_id ON vulnerability_occurrences USING gin (((location -> 'cluster_id'::text))) WHERE (report_type = 7); - CREATE INDEX index_vulnerability_occurrences_on_location_image ON vulnerability_occurrences USING gin (((location -> 'image'::text))) WHERE (report_type = ANY (ARRAY[2, 7])); +CREATE INDEX index_vulnerability_occurrences_on_location_k8s_agent_id ON vulnerability_occurrences USING gin ((((location -> 'kubernetes_resource'::text) -> 'agent_id'::text))) WHERE (report_type = 7); + +CREATE INDEX index_vulnerability_occurrences_on_location_k8s_cluster_id ON vulnerability_occurrences USING gin ((((location -> 'kubernetes_resource'::text) -> 'cluster_id'::text))) WHERE (report_type = 7); + CREATE INDEX index_vulnerability_occurrences_on_migrated_to_new_structure ON vulnerability_occurrences USING btree (migrated_to_new_structure, id); CREATE INDEX index_vulnerability_occurrences_on_primary_identifier_id ON vulnerability_occurrences USING btree (primary_identifier_id); @@ -30537,12 +30874,12 @@ CREATE INDEX index_vulnerability_occurrences_on_project_fingerprint ON vulnerabi CREATE INDEX index_vulnerability_occurrences_on_scanner_id ON vulnerability_occurrences USING btree (scanner_id); -CREATE UNIQUE INDEX index_vulnerability_occurrences_on_unique_keys ON vulnerability_occurrences USING btree (project_id, primary_identifier_id, location_fingerprint, scanner_id); - CREATE UNIQUE INDEX index_vulnerability_occurrences_on_uuid ON vulnerability_occurrences USING btree (uuid); CREATE INDEX index_vulnerability_occurrences_on_vulnerability_id ON vulnerability_occurrences USING btree (vulnerability_id); +CREATE INDEX index_vulnerability_reads_on_cluster_agent_id ON vulnerability_reads USING btree (cluster_agent_id) WHERE (report_type = 7); + CREATE INDEX index_vulnerability_reads_on_location_image ON vulnerability_reads USING btree (location_image) WHERE (report_type = ANY (ARRAY[2, 7])); CREATE INDEX index_vulnerability_reads_on_scanner_id ON vulnerability_reads USING btree (scanner_id); @@ -30651,6 +30988,10 @@ CREATE INDEX partial_index_deployments_for_legacy_successful_deployments ON depl CREATE INDEX partial_index_deployments_for_project_id_and_tag ON deployments USING btree (project_id) WHERE (tag IS TRUE); +CREATE UNIQUE INDEX partial_index_sop_configs_on_namespace_id ON security_orchestration_policy_configurations USING btree (namespace_id) WHERE (namespace_id IS NOT NULL); + +CREATE UNIQUE INDEX partial_index_sop_configs_on_project_id ON security_orchestration_policy_configurations USING btree (project_id) WHERE (project_id IS NOT NULL); + CREATE UNIQUE INDEX snippet_user_mentions_on_snippet_id_and_note_id_index ON snippet_user_mentions USING btree (snippet_id, note_id); CREATE UNIQUE INDEX snippet_user_mentions_on_snippet_id_index ON snippet_user_mentions USING btree (snippet_id) WHERE (note_id IS NULL); @@ -30659,9 +31000,19 @@ CREATE UNIQUE INDEX taggings_idx ON taggings USING btree (tag_id, taggable_id, t CREATE UNIQUE INDEX term_agreements_unique_index ON term_agreements USING btree (user_id, term_id); -CREATE INDEX tmp_idx_deduplicate_vulnerability_occurrences ON vulnerability_occurrences USING btree (project_id, report_type, location_fingerprint, primary_identifier_id, id); +CREATE INDEX tmp_gitlab_subscriptions_max_seats_used_migration ON gitlab_subscriptions USING btree (id) WHERE ((start_date >= '2021-08-02'::date) AND (start_date <= '2021-11-20'::date) AND (max_seats_used <> 0) AND (max_seats_used > seats_in_use) AND (max_seats_used > seats)); + +CREATE INDEX tmp_gitlab_subscriptions_max_seats_used_migration_2 ON gitlab_subscriptions USING btree (id) WHERE ((start_date < '2021-08-02'::date) AND (max_seats_used <> 0) AND (max_seats_used > seats_in_use) AND (max_seats_used > seats)); + +CREATE INDEX tmp_index_ci_job_artifacts_on_id_where_trace_and_expire_at ON ci_job_artifacts USING btree (id) WHERE ((file_type = 3) AND (expire_at = ANY (ARRAY['2021-04-22 00:00:00+00'::timestamp with time zone, '2021-05-22 00:00:00+00'::timestamp with time zone, '2021-06-22 00:00:00+00'::timestamp with time zone, '2022-01-22 00:00:00+00'::timestamp with time zone, '2022-02-22 00:00:00+00'::timestamp with time zone, '2022-03-22 00:00:00+00'::timestamp with time zone, '2022-04-22 00:00:00+00'::timestamp with time zone]))); + +CREATE INDEX tmp_index_container_repositories_on_id_migration_state ON container_repositories USING btree (id, migration_state); -CREATE INDEX tmp_index_ci_pipelines_lock_version ON ci_pipelines USING btree (id) WHERE (lock_version IS NULL); +CREATE INDEX tmp_index_for_namespace_id_migration_on_group_members ON members USING btree (id) WHERE ((member_namespace_id IS NULL) AND ((type)::text = 'GroupMember'::text)); + +CREATE INDEX tmp_index_for_namespace_id_migration_on_routes ON routes USING btree (id) WHERE ((namespace_id IS NULL) AND ((source_type)::text = 'Namespace'::text)); + +CREATE INDEX tmp_index_members_on_state ON members USING btree (state) WHERE (state = 2); CREATE INDEX tmp_index_namespaces_empty_traversal_ids_with_child_namespaces ON namespaces USING btree (id) WHERE ((parent_id IS NOT NULL) AND (traversal_ids = '{}'::integer[])); @@ -30671,6 +31022,10 @@ CREATE UNIQUE INDEX tmp_index_on_tmp_project_id_on_namespaces ON namespaces USIN CREATE INDEX tmp_index_on_vulnerabilities_non_dismissed ON vulnerabilities USING btree (id) WHERE (state <> 2); +CREATE INDEX tmp_index_projects_on_id_and_runners_token ON projects USING btree (id, runners_token) WHERE (runners_token IS NOT NULL); + +CREATE INDEX tmp_index_projects_on_id_and_runners_token_encrypted ON projects USING btree (id, runners_token_encrypted) WHERE (runners_token_encrypted IS NOT NULL); + CREATE UNIQUE INDEX uniq_pkgs_deb_grp_architectures_on_distribution_id_and_name ON packages_debian_group_architectures USING btree (distribution_id, name); CREATE UNIQUE INDEX uniq_pkgs_deb_grp_components_on_distribution_id_and_name ON packages_debian_group_components USING btree (distribution_id, name); @@ -30695,8 +31050,6 @@ CREATE UNIQUE INDEX vulnerability_feedback_unique_idx ON vulnerability_feedback CREATE UNIQUE INDEX vulnerability_occurrence_pipelines_on_unique_keys ON vulnerability_occurrence_pipelines USING btree (occurrence_id, pipeline_id); -CREATE INDEX vulnerability_occurrences_location_temp_index ON vulnerability_occurrences USING btree (id) WHERE (location IS NULL); - CREATE UNIQUE INDEX work_item_types_namespace_id_and_name_unique ON work_item_types USING btree (namespace_id, btrim(lower(name))); ALTER INDEX analytics_index_audit_events_part_on_created_at_and_author_id ATTACH PARTITION gitlab_partitions_dynamic.audit_events_000000_created_at_author_id_idx; @@ -30905,6 +31258,8 @@ ALTER INDEX index_incident_management_pending_issue_escalations_on_issue_id ATTA ALTER INDEX index_incident_management_pending_issue_escalations_on_issue_id ATTACH PARTITION gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202_issue_id_idx9; +ALTER INDEX index_loose_foreign_keys_deleted_records_for_partitioned_query ATTACH PARTITION gitlab_partitions_dynamic.index_01e3390fac; + ALTER INDEX index_web_hook_logs_part_on_web_hook_id ATTACH PARTITION gitlab_partitions_dynamic.index_1554dc6f11; ALTER INDEX index_web_hook_logs_part_on_web_hook_id ATTACH PARTITION gitlab_partitions_dynamic.index_719c6187cb; @@ -30913,6 +31268,8 @@ ALTER INDEX index_web_hook_logs_part_on_created_at_and_web_hook_id ATTACH PARTIT ALTER INDEX index_web_hook_logs_part_on_created_at_and_web_hook_id ATTACH PARTITION gitlab_partitions_dynamic.index_fdb8d5eeea; +ALTER INDEX loose_foreign_keys_deleted_records_pkey ATTACH PARTITION gitlab_partitions_dynamic.loose_foreign_keys_deleted_records_1_pkey; + ALTER INDEX verification_codes_pkey ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_000000_pkey; ALTER INDEX index_verification_codes_on_phone_and_visitor_id_code ATTACH PARTITION gitlab_partitions_dynamic.verification_codes_000000_visitor_id_code_phone_created_at_idx; @@ -31133,8 +31490,6 @@ ALTER INDEX index_issue_stage_events_project_duration ATTACH PARTITION gitlab_pa ALTER INDEX index_merge_request_stage_events_project_duration ATTACH PARTITION gitlab_partitions_static.index_006f943df6; -ALTER INDEX index_loose_foreign_keys_deleted_records_for_partitioned_query ATTACH PARTITION gitlab_partitions_static.index_01e3390fac; - ALTER INDEX index_merge_request_stage_events_project_duration ATTACH PARTITION gitlab_partitions_static.index_02749b504c; ALTER INDEX index_merge_request_stage_events_group_duration ATTACH PARTITION gitlab_partitions_static.index_0287f5ba09; @@ -32027,8 +32382,6 @@ ALTER INDEX issue_search_data_pkey ATTACH PARTITION gitlab_partitions_static.iss ALTER INDEX index_issue_search_data_on_search_vector ATTACH PARTITION gitlab_partitions_static.issue_search_data_63_search_vector_idx; -ALTER INDEX loose_foreign_keys_deleted_records_pkey ATTACH PARTITION gitlab_partitions_static.loose_foreign_keys_deleted_records_1_pkey; - ALTER INDEX index_product_analytics_events_experimental_project_and_time ATTACH PARTITION gitlab_partitions_static.product_analytics_events_expe_project_id_collector_tstamp_idx10; ALTER INDEX index_product_analytics_events_experimental_project_and_time ATTACH PARTITION gitlab_partitions_static.product_analytics_events_expe_project_id_collector_tstamp_idx11; @@ -32289,10 +32642,14 @@ CREATE TRIGGER chat_names_loose_fk_trigger AFTER DELETE ON chat_names REFERENCIN CREATE TRIGGER ci_builds_loose_fk_trigger AFTER DELETE ON ci_builds REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records(); +CREATE TRIGGER ci_job_artifacts_loose_fk_trigger AFTER DELETE ON ci_job_artifacts REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records(); + CREATE TRIGGER ci_pipelines_loose_fk_trigger AFTER DELETE ON ci_pipelines REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records(); CREATE TRIGGER ci_runners_loose_fk_trigger AFTER DELETE ON ci_runners REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records(); +CREATE TRIGGER merge_requests_loose_fk_trigger AFTER DELETE ON merge_requests REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records(); + CREATE TRIGGER namespaces_loose_fk_trigger AFTER DELETE ON namespaces REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records(); CREATE TRIGGER projects_loose_fk_trigger AFTER DELETE ON projects REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records(); @@ -32313,6 +32670,8 @@ CREATE TRIGGER trigger_has_external_wiki_on_type_new_updated AFTER UPDATE OF typ CREATE TRIGGER trigger_has_external_wiki_on_update AFTER UPDATE ON integrations FOR EACH ROW WHEN (((new.type_new = 'Integrations::ExternalWiki'::text) AND (old.active <> new.active) AND (new.project_id IS NOT NULL))) EXECUTE FUNCTION set_has_external_wiki(); +CREATE TRIGGER trigger_insert_or_update_vulnerability_reads_from_occurrences AFTER INSERT OR UPDATE ON vulnerability_occurrences FOR EACH ROW EXECUTE FUNCTION insert_or_update_vulnerability_reads(); + CREATE TRIGGER trigger_namespaces_parent_id_on_insert AFTER INSERT ON namespaces FOR EACH ROW EXECUTE FUNCTION insert_namespaces_sync_event(); CREATE TRIGGER trigger_namespaces_parent_id_on_update AFTER UPDATE ON namespaces FOR EACH ROW WHEN ((old.parent_id IS DISTINCT FROM new.parent_id)) EXECUTE FUNCTION insert_namespaces_sync_event(); @@ -32321,7 +32680,15 @@ CREATE TRIGGER trigger_projects_parent_id_on_insert AFTER INSERT ON projects FOR CREATE TRIGGER trigger_projects_parent_id_on_update AFTER UPDATE ON projects FOR EACH ROW WHEN ((old.namespace_id IS DISTINCT FROM new.namespace_id)) EXECUTE FUNCTION insert_projects_sync_event(); -CREATE TRIGGER trigger_type_new_on_insert AFTER INSERT ON integrations FOR EACH ROW EXECUTE FUNCTION integrations_set_type_new(); +CREATE TRIGGER trigger_update_has_issues_on_vulnerability_issue_links_delete AFTER DELETE ON vulnerability_issue_links FOR EACH ROW EXECUTE FUNCTION unset_has_issues_on_vulnerability_reads(); + +CREATE TRIGGER trigger_update_has_issues_on_vulnerability_issue_links_update AFTER INSERT ON vulnerability_issue_links FOR EACH ROW EXECUTE FUNCTION set_has_issues_on_vulnerability_reads(); + +CREATE TRIGGER trigger_update_location_on_vulnerability_occurrences_update AFTER UPDATE ON vulnerability_occurrences FOR EACH ROW WHEN (((new.report_type = ANY (ARRAY[2, 7])) AND (((old.location ->> 'image'::text) IS DISTINCT FROM (new.location ->> 'image'::text)) OR (((old.location -> 'kubernetes_resource'::text) ->> 'agent_id'::text) IS DISTINCT FROM ((new.location -> 'kubernetes_resource'::text) ->> 'agent_id'::text))))) EXECUTE FUNCTION update_location_from_vulnerability_occurrences(); + +CREATE TRIGGER trigger_update_vulnerability_reads_on_vulnerability_update AFTER UPDATE ON vulnerabilities FOR EACH ROW WHEN (((old.severity IS DISTINCT FROM new.severity) OR (old.state IS DISTINCT FROM new.state) OR (old.resolved_on_default_branch IS DISTINCT FROM new.resolved_on_default_branch))) EXECUTE FUNCTION update_vulnerability_reads_from_vulnerability(); + +CREATE TRIGGER users_loose_fk_trigger AFTER DELETE ON users REFERENCING OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE FUNCTION insert_into_loose_foreign_keys_deleted_records(); ALTER TABLE ONLY gitlab_partitions_dynamic.incident_management_pending_issue_escalations_202211 ADD CONSTRAINT fk_rails_0470889ee5 FOREIGN KEY (rule_id) REFERENCES incident_management_escalation_rules(id) ON DELETE CASCADE; @@ -32449,9 +32816,6 @@ ALTER TABLE ONLY agent_project_authorizations ALTER TABLE ONLY vulnerabilities ADD CONSTRAINT fk_1d37cddf91 FOREIGN KEY (epic_id) REFERENCES epics(id) ON DELETE SET NULL; -ALTER TABLE ONLY ci_sources_pipelines - ADD CONSTRAINT fk_1e53c97c0a FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY epics ADD CONSTRAINT fk_1fbed67632 FOREIGN KEY (start_date_sourcing_milestone_id) REFERENCES milestones(id) ON DELETE SET NULL; @@ -32470,9 +32834,6 @@ ALTER TABLE ONLY users_star_projects ALTER TABLE ONLY alert_management_alerts ADD CONSTRAINT fk_2358b75436 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE SET NULL; -ALTER TABLE ONLY ci_stages - ADD CONSTRAINT fk_2360681d1d FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY import_failures ADD CONSTRAINT fk_24b824da43 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; @@ -32506,9 +32867,6 @@ ALTER TABLE ONLY agent_group_authorizations ALTER TABLE ONLY deployment_approvals ADD CONSTRAINT fk_2d060dfc73 FOREIGN KEY (deployment_id) REFERENCES deployments(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_freeze_periods - ADD CONSTRAINT fk_2e02bbd1a6 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY notes ADD CONSTRAINT fk_2e82291620 FOREIGN KEY (review_id) REFERENCES reviews(id) ON DELETE SET NULL; @@ -32530,9 +32888,6 @@ ALTER TABLE ONLY approvals ALTER TABLE ONLY namespaces ADD CONSTRAINT fk_319256d87a FOREIGN KEY (file_template_project_id) REFERENCES projects(id) ON DELETE SET NULL; -ALTER TABLE ONLY ci_group_variables - ADD CONSTRAINT fk_33ae4d58d8 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; - ALTER TABLE ONLY namespaces ADD CONSTRAINT fk_3448c97865 FOREIGN KEY (push_rule_id) REFERENCES push_rules(id) ON DELETE SET NULL; @@ -32572,6 +32927,9 @@ ALTER TABLE ONLY epics ALTER TABLE ONLY ci_pipelines ADD CONSTRAINT fk_3d34ab2e06 FOREIGN KEY (pipeline_schedule_id) REFERENCES ci_pipeline_schedules(id) ON DELETE SET NULL; +ALTER TABLE ONLY merge_request_reviewers + ADD CONSTRAINT fk_3d674b9f23 FOREIGN KEY (updated_state_by_user_id) REFERENCES users(id) ON DELETE SET NULL; + ALTER TABLE ONLY ci_pipeline_schedule_variables ADD CONSTRAINT fk_41c35fda51 FOREIGN KEY (pipeline_schedule_id) REFERENCES ci_pipeline_schedules(id) ON DELETE CASCADE; @@ -32581,9 +32939,6 @@ ALTER TABLE ONLY geo_event_log ALTER TABLE ONLY incident_management_timeline_events ADD CONSTRAINT fk_4432fc4d78 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_runner_projects - ADD CONSTRAINT fk_4478a6f1e4 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY todos ADD CONSTRAINT fk_45054f9c45 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; @@ -32602,9 +32957,6 @@ ALTER TABLE ONLY alert_management_alerts ALTER TABLE ONLY path_locks ADD CONSTRAINT fk_5265c98f24 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; -ALTER TABLE ONLY dast_site_profiles_pipelines - ADD CONSTRAINT fk_53849b0ad5 FOREIGN KEY (ci_pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE; - ALTER TABLE ONLY terraform_states ADD CONSTRAINT fk_558901b030 FOREIGN KEY (locked_by_user_id) REFERENCES users(id) ON DELETE SET NULL; @@ -32653,8 +33005,8 @@ ALTER TABLE ONLY merge_requests ALTER TABLE ONLY ci_builds ADD CONSTRAINT fk_6661f4f0e8 FOREIGN KEY (resource_group_id) REFERENCES ci_resource_groups(id) ON DELETE SET NULL; -ALTER TABLE ONLY project_pages_metadata - ADD CONSTRAINT fk_69366a119e FOREIGN KEY (artifacts_archive_id) REFERENCES ci_job_artifacts(id) ON DELETE SET NULL; +ALTER TABLE ONLY routes + ADD CONSTRAINT fk_679ff8213d FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE SET NULL; ALTER TABLE ONLY application_settings ADD CONSTRAINT fk_693b8795e4 FOREIGN KEY (push_rule_id) REFERENCES push_rules(id) ON DELETE SET NULL; @@ -32681,7 +33033,7 @@ ALTER TABLE ONLY protected_branch_push_access_levels ADD CONSTRAINT fk_7111b68cdb FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; ALTER TABLE ONLY projects - ADD CONSTRAINT fk_71625606ac FOREIGN KEY (project_namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; + ADD CONSTRAINT fk_71625606ac FOREIGN KEY (project_namespace_id) REFERENCES namespaces(id) ON DELETE SET NULL; ALTER TABLE ONLY integrations ADD CONSTRAINT fk_71cce407f9 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; @@ -32701,9 +33053,6 @@ ALTER TABLE ONLY vulnerabilities ALTER TABLE ONLY oauth_openid_requests ADD CONSTRAINT fk_77114b3b09 FOREIGN KEY (access_grant_id) REFERENCES oauth_access_grants(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_resource_groups - ADD CONSTRAINT fk_774722d144 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY users ADD CONSTRAINT fk_789cd90b35 FOREIGN KEY (accepted_term_id) REFERENCES application_setting_terms(id) ON DELETE CASCADE; @@ -32716,9 +33065,6 @@ ALTER TABLE ONLY analytics_devops_adoption_snapshots ALTER TABLE ONLY lists ADD CONSTRAINT fk_7a5553d60f FOREIGN KEY (label_id) REFERENCES labels(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_unit_tests - ADD CONSTRAINT fk_7a8fabf0a8 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY protected_branches ADD CONSTRAINT fk_7a9c6d93e7 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; @@ -32761,9 +33107,6 @@ ALTER TABLE ONLY merge_request_diffs ALTER TABLE ONLY requirements ADD CONSTRAINT fk_85044baef0 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_pipelines - ADD CONSTRAINT fk_86635dbd80 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY geo_event_log ADD CONSTRAINT fk_86c84214ec FOREIGN KEY (repository_renamed_event_id) REFERENCES geo_repository_renamed_events(id) ON DELETE CASCADE; @@ -32797,9 +33140,6 @@ ALTER TABLE ONLY releases ALTER TABLE ONLY protected_tags ADD CONSTRAINT fk_8e4af87648 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_pipeline_schedules - ADD CONSTRAINT fk_8ead60fcc4 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY todos ADD CONSTRAINT fk_91d1f47b13 FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE; @@ -32854,9 +33194,6 @@ ALTER TABLE ONLY protected_environments ALTER TABLE ONLY alert_management_alerts ADD CONSTRAINT fk_9e49e5c2b7 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_pipeline_schedules - ADD CONSTRAINT fk_9ea99f58d2 FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE SET NULL; - ALTER TABLE ONLY protected_branch_push_access_levels ADD CONSTRAINT fk_9ffc86a3d9 FOREIGN KEY (protected_branch_id) REFERENCES protected_branches(id) ON DELETE CASCADE; @@ -32869,15 +33206,9 @@ ALTER TABLE ONLY issues ALTER TABLE ONLY ci_builds ADD CONSTRAINT fk_a2141b1522 FOREIGN KEY (auto_canceled_by_id) REFERENCES ci_pipelines(id) ON DELETE SET NULL; -ALTER TABLE ONLY ci_pipelines - ADD CONSTRAINT fk_a23be95014 FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE; - ALTER TABLE ONLY todos ADD CONSTRAINT fk_a27c483435 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; -ALTER TABLE ONLY dast_site_profiles_builds - ADD CONSTRAINT fk_a325505e99 FOREIGN KEY (ci_build_id) REFERENCES ci_builds(id) ON DELETE CASCADE; - ALTER TABLE ONLY jira_connect_subscriptions ADD CONSTRAINT fk_a3c10bcf7d FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; @@ -32887,12 +33218,12 @@ ALTER TABLE ONLY bulk_import_entities ALTER TABLE ONLY users ADD CONSTRAINT fk_a4b8fefe3e FOREIGN KEY (managing_group_id) REFERENCES namespaces(id) ON DELETE SET NULL; +ALTER TABLE ONLY security_orchestration_policy_configurations + ADD CONSTRAINT fk_a50430b375 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; + ALTER TABLE ONLY lfs_objects_projects ADD CONSTRAINT fk_a56e02279c FOREIGN KEY (lfs_object_id) REFERENCES lfs_objects(id) ON DELETE RESTRICT NOT VALID; -ALTER TABLE ONLY dast_profiles_pipelines - ADD CONSTRAINT fk_a60cad829d FOREIGN KEY (ci_pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE; - ALTER TABLE ONLY merge_requests ADD CONSTRAINT fk_a6963e8447 FOREIGN KEY (target_project_id) REFERENCES projects(id) ON DELETE CASCADE; @@ -32902,6 +33233,9 @@ ALTER TABLE ONLY epics ALTER TABLE ONLY dast_profiles ADD CONSTRAINT fk_aa76ef30e9 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; +ALTER TABLE ONLY members + ADD CONSTRAINT fk_aa82dcc1c6 FOREIGN KEY (member_namespace_id) REFERENCES namespaces(id) ON DELETE SET NULL; + ALTER TABLE ONLY alert_management_alerts ADD CONSTRAINT fk_aad61aedca FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE SET NULL; @@ -32914,21 +33248,18 @@ ALTER TABLE ONLY boards ALTER TABLE ONLY member_tasks ADD CONSTRAINT fk_ab636303dd FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_sources_pipelines - ADD CONSTRAINT fk_acd9737679 FOREIGN KEY (source_project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY merge_requests ADD CONSTRAINT fk_ad525e1f87 FOREIGN KEY (merge_user_id) REFERENCES users(id) ON DELETE SET NULL; -ALTER TABLE ONLY ci_variables - ADD CONSTRAINT fk_ada5eb64b3 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY merge_request_metrics ADD CONSTRAINT fk_ae440388cc FOREIGN KEY (latest_closed_by_id) REFERENCES users(id) ON DELETE SET NULL; ALTER TABLE ONLY dast_profile_schedules ADD CONSTRAINT fk_aef03d62e5 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL; +ALTER TABLE ONLY merge_request_assignees + ADD CONSTRAINT fk_af036e3261 FOREIGN KEY (updated_state_by_user_id) REFERENCES users(id) ON DELETE SET NULL; + ALTER TABLE ONLY analytics_cycle_analytics_group_stages ADD CONSTRAINT fk_analytics_cycle_analytics_group_stages_group_value_stream_id FOREIGN KEY (group_value_stream_id) REFERENCES analytics_cycle_analytics_group_value_streams(id) ON DELETE CASCADE; @@ -32992,9 +33323,6 @@ ALTER TABLE ONLY ci_sources_pipelines ALTER TABLE ONLY packages_maven_metadata ADD CONSTRAINT fk_be88aed360 FOREIGN KEY (package_id) REFERENCES packages_packages(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_builds - ADD CONSTRAINT fk_befce0568a FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY design_management_versions ADD CONSTRAINT fk_c1440b4896 FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE SET NULL; @@ -33127,11 +33455,8 @@ ALTER TABLE ONLY ci_builds_metadata ALTER TABLE ONLY gitlab_subscriptions ADD CONSTRAINT fk_e2595d00a1 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_triggers - ADD CONSTRAINT fk_e3e63f966e FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - -ALTER TABLE ONLY dast_scanner_profiles_builds - ADD CONSTRAINT fk_e4c49200f8 FOREIGN KEY (ci_build_id) REFERENCES ci_builds(id) ON DELETE CASCADE; +ALTER TABLE ONLY ci_builds + ADD CONSTRAINT fk_e4ef9c2f27 FOREIGN KEY (runner_id) REFERENCES ci_runners(id) ON DELETE SET NULL NOT VALID; ALTER TABLE ONLY merge_requests ADD CONSTRAINT fk_e719a85f8a FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE SET NULL; @@ -33154,12 +33479,6 @@ ALTER TABLE ONLY sprints ALTER TABLE ONLY application_settings ADD CONSTRAINT fk_e8a145f3a7 FOREIGN KEY (instance_administrators_group_id) REFERENCES namespaces(id) ON DELETE SET NULL; -ALTER TABLE ONLY vulnerability_statistics - ADD CONSTRAINT fk_e8b13c928f FOREIGN KEY (latest_pipeline_id) REFERENCES ci_pipelines(id) ON DELETE SET NULL; - -ALTER TABLE ONLY ci_triggers - ADD CONSTRAINT fk_e8e10d1964 FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE; - ALTER TABLE ONLY integrations ADD CONSTRAINT fk_e8fe908a34 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; @@ -33232,15 +33551,6 @@ ALTER TABLE ONLY system_note_metadata ALTER TABLE ONLY vulnerability_remediations ADD CONSTRAINT fk_fc61a535a0 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_daily_build_group_report_results - ADD CONSTRAINT fk_fd1858fefd FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; - -ALTER TABLE ONLY merge_requests - ADD CONSTRAINT fk_fd82eae0b9 FOREIGN KEY (head_pipeline_id) REFERENCES ci_pipelines(id) ON DELETE SET NULL; - -ALTER TABLE ONLY ci_pending_builds - ADD CONSTRAINT fk_fdc0137e4a FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; - ALTER TABLE ONLY project_import_data ADD CONSTRAINT fk_ffb9ee3a10 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; @@ -33295,15 +33605,6 @@ ALTER TABLE ONLY ip_restrictions ALTER TABLE ONLY terraform_state_versions ADD CONSTRAINT fk_rails_04f176e239 FOREIGN KEY (terraform_state_id) REFERENCES terraform_states(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_build_report_results - ADD CONSTRAINT fk_rails_056d298d48 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - -ALTER TABLE ONLY ci_daily_build_group_report_results - ADD CONSTRAINT fk_rails_0667f7608c FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - -ALTER TABLE ONLY ci_subscriptions_projects - ADD CONSTRAINT fk_rails_0818751483 FOREIGN KEY (downstream_project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY user_interacted_projects ADD CONSTRAINT fk_rails_0894651f08 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; @@ -33322,6 +33623,9 @@ ALTER TABLE ONLY packages_debian_group_distributions ALTER TABLE ONLY packages_conan_file_metadata ADD CONSTRAINT fk_rails_0afabd9328 FOREIGN KEY (package_file_id) REFERENCES packages_package_files(id) ON DELETE CASCADE; +ALTER TABLE ONLY related_epic_links + ADD CONSTRAINT fk_rails_0b72027748 FOREIGN KEY (target_id) REFERENCES epics(id) ON DELETE CASCADE; + ALTER TABLE ONLY ci_build_pending_states ADD CONSTRAINT fk_rails_0bbbfeaf9d FOREIGN KEY (build_id) REFERENCES ci_builds(id) ON DELETE CASCADE; @@ -33388,6 +33692,9 @@ ALTER TABLE ONLY bulk_imports ALTER TABLE ONLY diff_note_positions ADD CONSTRAINT fk_rails_13c7212859 FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE; +ALTER TABLE ONLY analytics_cycle_analytics_aggregations + ADD CONSTRAINT fk_rails_13c8374c7a FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; + ALTER TABLE ONLY users_security_dashboard_projects ADD CONSTRAINT fk_rails_150cd5682c FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; @@ -33469,9 +33776,6 @@ ALTER TABLE ONLY boards_epic_lists ALTER TABLE ONLY approval_merge_request_rules_groups ADD CONSTRAINT fk_rails_2020a7124a FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; -ALTER TABLE ONLY vulnerability_feedback - ADD CONSTRAINT fk_rails_20976e6fd9 FOREIGN KEY (pipeline_id) REFERENCES ci_pipelines(id) ON DELETE SET NULL; - ALTER TABLE ONLY work_item_types ADD CONSTRAINT fk_rails_20f694a960 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; @@ -33490,9 +33794,6 @@ ALTER TABLE ONLY service_desk_settings ALTER TABLE ONLY saml_group_links ADD CONSTRAINT fk_rails_22e312c530 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; -ALTER TABLE ONLY vulnerability_finding_evidence_responses - ADD CONSTRAINT fk_rails_2390a09723 FOREIGN KEY (vulnerability_finding_evidence_id) REFERENCES vulnerability_finding_evidences(id) ON DELETE CASCADE; - ALTER TABLE ONLY dast_profiles ADD CONSTRAINT fk_rails_23cae5abe1 FOREIGN KEY (dast_scanner_profile_id) REFERENCES dast_scanner_profiles(id) ON DELETE CASCADE; @@ -33592,8 +33893,8 @@ ALTER TABLE ONLY container_repositories ALTER TABLE ONLY clusters_applications_jupyter ADD CONSTRAINT fk_rails_331f0aff78 FOREIGN KEY (oauth_application_id) REFERENCES oauth_applications(id) ON DELETE SET NULL; -ALTER TABLE ONLY merge_request_metrics - ADD CONSTRAINT fk_rails_33ae169d48 FOREIGN KEY (pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE; +ALTER TABLE ONLY alert_management_alert_metric_images + ADD CONSTRAINT fk_rails_338e55b408 FOREIGN KEY (alert_id) REFERENCES alert_management_alerts(id) ON DELETE CASCADE; ALTER TABLE ONLY suggestions ADD CONSTRAINT fk_rails_33b03a535c FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE; @@ -33604,12 +33905,12 @@ ALTER TABLE ONLY requirements ALTER TABLE ONLY metrics_dashboard_annotations ADD CONSTRAINT fk_rails_345ab51043 FOREIGN KEY (cluster_id) REFERENCES clusters(id) ON DELETE CASCADE; +ALTER TABLE ONLY group_features + ADD CONSTRAINT fk_rails_356514082b FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; + ALTER TABLE ONLY wiki_page_slugs ADD CONSTRAINT fk_rails_358b46be14 FOREIGN KEY (wiki_page_meta_id) REFERENCES wiki_page_meta(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_job_token_project_scope_links - ADD CONSTRAINT fk_rails_35f7f506ce FOREIGN KEY (added_by_id) REFERENCES users(id) ON DELETE SET NULL; - ALTER TABLE ONLY board_labels ADD CONSTRAINT fk_rails_362b0600a3 FOREIGN KEY (label_id) REFERENCES labels(id) ON DELETE CASCADE; @@ -33685,9 +33986,6 @@ ALTER TABLE ONLY geo_node_namespace_links ALTER TABLE ONLY epic_issues ADD CONSTRAINT fk_rails_4209981af6 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_refs - ADD CONSTRAINT fk_rails_4249db8cc3 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY ci_resources ADD CONSTRAINT fk_rails_430336af2d FOREIGN KEY (resource_group_id) REFERENCES ci_resource_groups(id) ON DELETE CASCADE; @@ -33733,18 +34031,9 @@ ALTER TABLE ONLY vulnerability_feedback ALTER TABLE ONLY user_custom_attributes ADD CONSTRAINT fk_rails_47b91868a8 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_pending_builds - ADD CONSTRAINT fk_rails_480669c3b3 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY upcoming_reconciliations ADD CONSTRAINT fk_rails_497b4938ac FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_pipeline_artifacts - ADD CONSTRAINT fk_rails_4a70390ca6 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - -ALTER TABLE ONLY ci_job_token_project_scope_links - ADD CONSTRAINT fk_rails_4b2ee3290b FOREIGN KEY (source_project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY group_deletion_schedules ADD CONSTRAINT fk_rails_4b8c694a6c FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; @@ -33769,6 +34058,9 @@ ALTER TABLE ONLY scim_identities ALTER TABLE ONLY snippet_user_mentions ADD CONSTRAINT fk_rails_4d3f96b2cb FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE; +ALTER TABLE ONLY protected_environment_approval_rules + ADD CONSTRAINT fk_rails_4e554f96f5 FOREIGN KEY (protected_environment_id) REFERENCES protected_environments(id) ON DELETE CASCADE; + ALTER TABLE ONLY deployment_clusters ADD CONSTRAINT fk_rails_4e6243e120 FOREIGN KEY (cluster_id) REFERENCES clusters(id) ON DELETE CASCADE; @@ -33778,9 +34070,6 @@ ALTER TABLE ONLY geo_repository_renamed_events ALTER TABLE ONLY aws_roles ADD CONSTRAINT fk_rails_4ed56f4720 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; -ALTER TABLE ONLY security_scans - ADD CONSTRAINT fk_rails_4ef1e6b4c6 FOREIGN KEY (build_id) REFERENCES ci_builds(id) ON DELETE CASCADE; - ALTER TABLE ONLY packages_debian_publications ADD CONSTRAINT fk_rails_4fc8ebd03e FOREIGN KEY (distribution_id) REFERENCES packages_debian_project_distributions(id) ON DELETE CASCADE; @@ -33793,9 +34082,6 @@ ALTER TABLE ONLY resource_iteration_events ALTER TABLE ONLY status_page_settings ADD CONSTRAINT fk_rails_506e5ba391 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_project_monthly_usages - ADD CONSTRAINT fk_rails_508bcd4aa6 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY project_repository_storage_moves ADD CONSTRAINT fk_rails_5106dbd44a FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; @@ -33907,9 +34193,6 @@ ALTER TABLE ONLY evidences ALTER TABLE ONLY jira_imports ADD CONSTRAINT fk_rails_63cbe52ada FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; -ALTER TABLE ONLY vulnerability_occurrence_pipelines - ADD CONSTRAINT fk_rails_6421e35d7d FOREIGN KEY (pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE; - ALTER TABLE ONLY group_deploy_tokens ADD CONSTRAINT fk_rails_6477b01f6b FOREIGN KEY (deploy_token_id) REFERENCES deploy_tokens(id) ON DELETE CASCADE; @@ -33919,9 +34202,6 @@ ALTER TABLE ONLY reviews ALTER TABLE ONLY operations_feature_flags ADD CONSTRAINT fk_rails_648e241be7 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_sources_projects - ADD CONSTRAINT fk_rails_64b6855cbc FOREIGN KEY (source_project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY board_group_recent_visits ADD CONSTRAINT fk_rails_64bfc19bc5 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; @@ -33958,15 +34238,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; -ALTER TABLE ONLY ci_job_token_project_scope_links - ADD CONSTRAINT fk_rails_6904b38465 FOREIGN KEY (target_project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY plan_limits ADD CONSTRAINT fk_rails_69f8b6184f FOREIGN KEY (plan_id) REFERENCES plans(id) ON DELETE CASCADE; @@ -33982,9 +34256,6 @@ ALTER TABLE ONLY prometheus_alerts ALTER TABLE ONLY term_agreements ADD CONSTRAINT fk_rails_6ea6520e4a FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; -ALTER TABLE ONLY vulnerability_finding_evidence_assets - ADD CONSTRAINT fk_rails_6edbbecba4 FOREIGN KEY (vulnerability_finding_evidence_id) REFERENCES vulnerability_finding_evidences(id) ON DELETE CASCADE; - ALTER TABLE ONLY project_compliance_framework_settings ADD CONSTRAINT fk_rails_6f5294f16c FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; @@ -34018,9 +34289,6 @@ ALTER TABLE ONLY dast_scanner_profiles ALTER TABLE ONLY vulnerability_historical_statistics ADD CONSTRAINT fk_rails_72b73ed023 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; -ALTER TABLE ONLY vulnerability_finding_evidence_requests - ADD CONSTRAINT fk_rails_72c87c8eb6 FOREIGN KEY (vulnerability_finding_evidence_id) REFERENCES vulnerability_finding_evidences(id) ON DELETE CASCADE; - ALTER TABLE ONLY slack_integrations ADD CONSTRAINT fk_rails_73db19721a FOREIGN KEY (service_id) REFERENCES integrations(id) ON DELETE CASCADE; @@ -34036,6 +34304,9 @@ ALTER TABLE ONLY dast_site_profiles ALTER TABLE ONLY merge_request_context_commit_diff_files ADD CONSTRAINT fk_rails_74a00a1787 FOREIGN KEY (merge_request_context_commit_id) REFERENCES merge_request_context_commits(id) ON DELETE CASCADE; +ALTER TABLE ONLY group_crm_settings + ADD CONSTRAINT fk_rails_74fdf2f13d FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; + ALTER TABLE ONLY clusters_applications_ingress ADD CONSTRAINT fk_rails_753a7b41c1 FOREIGN KEY (cluster_id) REFERENCES clusters(id) ON DELETE CASCADE; @@ -34066,18 +34337,12 @@ ALTER TABLE ONLY boards_epic_user_preferences ALTER TABLE ONLY packages_debian_group_distribution_keys ADD CONSTRAINT fk_rails_779438f163 FOREIGN KEY (distribution_id) REFERENCES packages_debian_group_distributions(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_subscriptions_projects - ADD CONSTRAINT fk_rails_7871f9a97b FOREIGN KEY (upstream_project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY terraform_states ADD CONSTRAINT fk_rails_78f54ca485 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; ALTER TABLE ONLY analytics_cycle_analytics_project_stages ADD CONSTRAINT fk_rails_796a7dbc9c FOREIGN KEY (project_value_stream_id) REFERENCES analytics_cycle_analytics_project_value_streams(id) ON DELETE CASCADE; -ALTER TABLE ONLY vulnerability_finding_evidence_supporting_messages - ADD CONSTRAINT fk_rails_79e77f6c5c FOREIGN KEY (vulnerability_finding_evidence_id) REFERENCES vulnerability_finding_evidences(id) ON DELETE CASCADE; - ALTER TABLE ONLY software_license_policies ADD CONSTRAINT fk_rails_7a7a2a92de FOREIGN KEY (software_license_id) REFERENCES software_licenses(id) ON DELETE CASCADE; @@ -34111,6 +34376,9 @@ ALTER TABLE ONLY required_code_owners_sections ALTER TABLE ONLY dast_site_profiles ADD CONSTRAINT fk_rails_83e309d69e FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; +ALTER TABLE ONLY security_trainings + ADD CONSTRAINT fk_rails_84c7951d72 FOREIGN KEY (provider_id) REFERENCES security_training_providers(id) ON DELETE CASCADE; + ALTER TABLE ONLY zentao_tracker_data ADD CONSTRAINT fk_rails_84efda7be0 FOREIGN KEY (integration_id) REFERENCES integrations(id) ON DELETE CASCADE; @@ -34207,12 +34475,12 @@ ALTER TABLE ONLY project_error_tracking_settings ALTER TABLE ONLY list_user_preferences ADD CONSTRAINT fk_rails_916d72cafd FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; -ALTER TABLE ONLY vulnerability_finding_evidence_responses - ADD CONSTRAINT fk_rails_929041a499 FOREIGN KEY (vulnerability_finding_evidence_supporting_message_id) REFERENCES vulnerability_finding_evidence_supporting_messages(id) ON DELETE CASCADE; - ALTER TABLE ONLY merge_request_cleanup_schedules ADD CONSTRAINT fk_rails_92dd0e705c FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE; +ALTER TABLE ONLY project_build_artifacts_size_refreshes + ADD CONSTRAINT fk_rails_936db5fc44 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; + ALTER TABLE ONLY board_labels ADD CONSTRAINT fk_rails_9374a16edd FOREIGN KEY (board_id) REFERENCES boards(id) ON DELETE CASCADE; @@ -34243,9 +34511,6 @@ ALTER TABLE ONLY group_repository_storage_moves ALTER TABLE ONLY resource_label_events ADD CONSTRAINT fk_rails_9851a00031 FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_job_artifacts - ADD CONSTRAINT fk_rails_9862d392f9 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY board_project_recent_visits ADD CONSTRAINT fk_rails_98f8843922 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; @@ -34351,6 +34616,9 @@ ALTER TABLE ONLY resource_milestone_events ALTER TABLE ONLY term_agreements ADD CONSTRAINT fk_rails_a88721bcdf FOREIGN KEY (term_id) REFERENCES application_setting_terms(id); +ALTER TABLE ONLY saved_replies + ADD CONSTRAINT fk_rails_a8bf5bf111 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; + ALTER TABLE ONLY ci_pipeline_artifacts ADD CONSTRAINT fk_rails_a9e811a466 FOREIGN KEY (pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE; @@ -34456,9 +34724,6 @@ ALTER TABLE ONLY projects_sync_events ALTER TABLE ONLY approval_merge_request_rules_users ADD CONSTRAINT fk_rails_bc8972fa55 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; -ALTER TABLE ONLY external_pull_requests - ADD CONSTRAINT fk_rails_bcae9b5c7b FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY elasticsearch_indexed_projects ADD CONSTRAINT fk_rails_bd13bbdc3d FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; @@ -34510,6 +34775,9 @@ ALTER TABLE ONLY group_deploy_keys_groups ALTER TABLE ONLY merge_request_user_mentions ADD CONSTRAINT fk_rails_c440b9ea31 FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE; +ALTER TABLE ONLY related_epic_links + ADD CONSTRAINT fk_rails_c464534def FOREIGN KEY (source_id) REFERENCES epics(id) ON DELETE CASCADE; + ALTER TABLE ONLY boards_epic_board_recent_visits ADD CONSTRAINT fk_rails_c4dcba4a3e FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; @@ -34567,18 +34835,12 @@ ALTER TABLE ONLY operations_strategies_user_lists ALTER TABLE ONLY issue_tracker_data ADD CONSTRAINT fk_rails_ccc0840427 FOREIGN KEY (service_id) REFERENCES integrations(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; ALTER TABLE ONLY resource_iteration_events ADD CONSTRAINT fk_rails_cee126f66c FOREIGN KEY (iteration_id) REFERENCES sprints(id) ON DELETE CASCADE; -ALTER TABLE ONLY vulnerability_finding_evidence_requests - ADD CONSTRAINT fk_rails_cf0f278cb0 FOREIGN KEY (vulnerability_finding_evidence_supporting_message_id) REFERENCES vulnerability_finding_evidence_supporting_messages(id) ON DELETE CASCADE; - ALTER TABLE ONLY upload_states ADD CONSTRAINT fk_rails_d00f153613 FOREIGN KEY (upload_id) REFERENCES uploads(id) ON DELETE CASCADE; @@ -34633,9 +34895,6 @@ ALTER TABLE ONLY issues_prometheus_alert_events ALTER TABLE ONLY board_user_preferences ADD CONSTRAINT fk_rails_dbebdaa8fe FOREIGN KEY (board_id) REFERENCES boards(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_running_builds - ADD CONSTRAINT fk_rails_dc1d0801e8 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY vulnerability_occurrence_pipelines ADD CONSTRAINT fk_rails_dc3ae04693 FOREIGN KEY (occurrence_id) REFERENCES vulnerability_occurrences(id) ON DELETE CASCADE; @@ -34663,9 +34922,6 @@ ALTER TABLE ONLY analytics_cycle_analytics_group_stages ALTER TABLE ONLY bulk_import_export_uploads ADD CONSTRAINT fk_rails_dfbfb45eca FOREIGN KEY (export_id) REFERENCES bulk_import_exports(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_minutes_additional_packs - ADD CONSTRAINT fk_rails_e0e0c4e4b1 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; - ALTER TABLE ONLY label_priorities ADD CONSTRAINT fk_rails_e161058b0f FOREIGN KEY (label_id) REFERENCES labels(id) ON DELETE CASCADE; @@ -34705,9 +34961,6 @@ ALTER TABLE ONLY approval_merge_request_rule_sources ALTER TABLE ONLY prometheus_alerts ADD CONSTRAINT fk_rails_e6351447ec FOREIGN KEY (prometheus_metric_id) REFERENCES prometheus_metrics(id) ON DELETE CASCADE; -ALTER TABLE ONLY requirements_management_test_reports - ADD CONSTRAINT fk_rails_e67d085910 FOREIGN KEY (build_id) REFERENCES ci_builds(id) ON DELETE SET NULL; - ALTER TABLE ONLY merge_request_metrics ADD CONSTRAINT fk_rails_e6d7c24d1b FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE; @@ -34735,9 +34988,6 @@ ALTER TABLE ONLY vulnerability_issue_links ALTER TABLE ONLY merge_request_blocks ADD CONSTRAINT fk_rails_e9387863bc FOREIGN KEY (blocking_merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE; -ALTER TABLE ONLY vulnerability_finding_evidence_sources - ADD CONSTRAINT fk_rails_e9761bed4c FOREIGN KEY (vulnerability_finding_evidence_id) REFERENCES vulnerability_finding_evidences(id) ON DELETE CASCADE; - ALTER TABLE ONLY protected_branch_unprotect_access_levels ADD CONSTRAINT fk_rails_e9eb8dc025 FOREIGN KEY (protected_branch_id) REFERENCES protected_branches(id) ON DELETE CASCADE; @@ -34825,15 +35075,12 @@ ALTER TABLE ONLY internal_ids ALTER TABLE ONLY issues_self_managed_prometheus_alert_events ADD CONSTRAINT fk_rails_f7db2d72eb FOREIGN KEY (self_managed_prometheus_alert_event_id) REFERENCES self_managed_prometheus_alert_events(id) ON DELETE CASCADE; +ALTER TABLE ONLY security_trainings + ADD CONSTRAINT fk_rails_f80240fae0 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; + ALTER TABLE ONLY merge_requests_closing_issues ADD CONSTRAINT fk_rails_f8540692be FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE; -ALTER TABLE ONLY merge_trains - ADD CONSTRAINT fk_rails_f90820cb08 FOREIGN KEY (pipeline_id) REFERENCES ci_pipelines(id) ON DELETE SET NULL; - -ALTER TABLE ONLY ci_runner_namespaces - ADD CONSTRAINT fk_rails_f9d9ed3308 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; - ALTER TABLE ONLY banned_users ADD CONSTRAINT fk_rails_fa5bb598e5 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; @@ -34876,9 +35123,6 @@ ALTER TABLE ONLY resource_label_events ALTER TABLE ONLY pages_deployment_states ADD CONSTRAINT fk_rails_ff6ca551a4 FOREIGN KEY (pages_deployment_id) REFERENCES pages_deployments(id) ON DELETE CASCADE; -ALTER TABLE ONLY ci_builds_metadata - ADD CONSTRAINT fk_rails_ffcf702a02 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; - ALTER TABLE ONLY security_orchestration_policy_configurations ADD CONSTRAINT fk_security_policy_configurations_management_project_id FOREIGN KEY (security_policy_management_project_id) REFERENCES projects(id) ON DELETE CASCADE; |