summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-04-14 06:18:27 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-04-14 06:18:27 +0000
commitc192f26df39e9a2ab122c2d097b86e461599bde8 (patch)
tree405f7ce164bcf33ce178699048b137a8712990a0 /db
parent361def36660a93176d8cb32fb47412dbb1100c2b (diff)
downloadgitlab-ce-c192f26df39e9a2ab122c2d097b86e461599bde8.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/docs/abuse_trust_scores.yml10
-rw-r--r--db/migrate/20230411171001_create_abuse_trust_scores.rb16
-rw-r--r--db/schema_migrations/202304111710011
-rw-r--r--db/structure.sql30
4 files changed, 57 insertions, 0 deletions
diff --git a/db/docs/abuse_trust_scores.yml b/db/docs/abuse_trust_scores.yml
new file mode 100644
index 00000000000..75a8888e069
--- /dev/null
+++ b/db/docs/abuse_trust_scores.yml
@@ -0,0 +1,10 @@
+---
+table_name: abuse_trust_scores
+classes:
+- Abuse::TrustScore
+feature_categories:
+- instance_resiliency
+description: Aggregates per-user scores related to potential product abuse.
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/117301
+milestone: '15.11'
+gitlab_schema: gitlab_main
diff --git a/db/migrate/20230411171001_create_abuse_trust_scores.rb b/db/migrate/20230411171001_create_abuse_trust_scores.rb
new file mode 100644
index 00000000000..2c95a2ab01e
--- /dev/null
+++ b/db/migrate/20230411171001_create_abuse_trust_scores.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class CreateAbuseTrustScores < Gitlab::Database::Migration[2.1]
+ def change
+ create_table :abuse_trust_scores do |t|
+ t.belongs_to :user, foreign_key: { to_table: :users, on_delete: :cascade }, index: false
+
+ t.float :score, null: false
+ t.timestamps_with_timezone null: false
+ t.integer :source, limit: 2, null: false
+ t.text :correlation_id_value, limit: 32
+
+ t.index [:user_id, :source, :created_at]
+ end
+ end
+end
diff --git a/db/schema_migrations/20230411171001 b/db/schema_migrations/20230411171001
new file mode 100644
index 00000000000..59b8c273f19
--- /dev/null
+++ b/db/schema_migrations/20230411171001
@@ -0,0 +1 @@
+7182fb09394b77f01346e68b104a5a8814f48fd63e763207f1b983faae10d805 \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index c274a315449..f74e15b2b9f 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -10760,6 +10760,26 @@ CREATE SEQUENCE abuse_reports_id_seq
ALTER SEQUENCE abuse_reports_id_seq OWNED BY abuse_reports.id;
+CREATE TABLE abuse_trust_scores (
+ id bigint NOT NULL,
+ user_id bigint,
+ score double precision NOT NULL,
+ created_at timestamp with time zone NOT NULL,
+ updated_at timestamp with time zone NOT NULL,
+ source smallint NOT NULL,
+ correlation_id_value text,
+ CONSTRAINT check_77ca9551db CHECK ((char_length(correlation_id_value) <= 32))
+);
+
+CREATE SEQUENCE abuse_trust_scores_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+ALTER SEQUENCE abuse_trust_scores_id_seq OWNED BY abuse_trust_scores.id;
+
CREATE TABLE achievements (
id bigint NOT NULL,
namespace_id bigint NOT NULL,
@@ -24504,6 +24524,8 @@ ALTER SEQUENCE zoom_meetings_id_seq OWNED BY zoom_meetings.id;
ALTER TABLE ONLY abuse_reports ALTER COLUMN id SET DEFAULT nextval('abuse_reports_id_seq'::regclass);
+ALTER TABLE ONLY abuse_trust_scores ALTER COLUMN id SET DEFAULT nextval('abuse_trust_scores_id_seq'::regclass);
+
ALTER TABLE ONLY achievements ALTER COLUMN id SET DEFAULT nextval('achievements_id_seq'::regclass);
ALTER TABLE ONLY agent_activity_events ALTER COLUMN id SET DEFAULT nextval('agent_activity_events_id_seq'::regclass);
@@ -26197,6 +26219,9 @@ ALTER TABLE ONLY gitlab_partitions_static.product_analytics_events_experimental_
ALTER TABLE ONLY abuse_reports
ADD CONSTRAINT abuse_reports_pkey PRIMARY KEY (id);
+ALTER TABLE ONLY abuse_trust_scores
+ ADD CONSTRAINT abuse_trust_scores_pkey PRIMARY KEY (id);
+
ALTER TABLE ONLY achievements
ADD CONSTRAINT achievements_pkey PRIMARY KEY (id);
@@ -29362,6 +29387,8 @@ CREATE INDEX index_abuse_reports_on_status_reporter_id_and_id ON abuse_reports U
CREATE INDEX index_abuse_reports_on_user_id ON abuse_reports USING btree (user_id);
+CREATE INDEX index_abuse_trust_scores_on_user_id_and_source_and_created_at ON abuse_trust_scores USING btree (user_id, source, created_at);
+
CREATE UNIQUE INDEX "index_achievements_on_namespace_id_LOWER_name" ON achievements USING btree (namespace_id, lower(name));
CREATE INDEX index_agent_activity_events_on_agent_id_and_recorded_at_and_id ON agent_activity_events USING btree (agent_id, recorded_at, id);
@@ -36532,6 +36559,9 @@ ALTER TABLE ONLY approval_project_rules_protected_branches
ALTER TABLE ONLY packages_composer_cache_files
ADD CONSTRAINT fk_rails_b82cea43a0 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE SET NULL;
+ALTER TABLE ONLY abuse_trust_scores
+ ADD CONSTRAINT fk_rails_b903079eb4 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY dora_configurations
ADD CONSTRAINT fk_rails_b9b8d90ddb FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;