diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/docs/ml_candidate_metrics.yml | 10 | ||||
-rw-r--r-- | db/docs/ml_candidate_params.yml | 10 | ||||
-rw-r--r-- | db/docs/ml_candidates.yml | 10 | ||||
-rw-r--r-- | db/docs/ml_experiments.yml | 10 | ||||
-rw-r--r-- | db/migrate/20220811092243_create_ml_experiments.rb | 18 | ||||
-rw-r--r-- | db/migrate/20220811092244_create_ml_candidates.rb | 16 | ||||
-rw-r--r-- | db/migrate/20220811092245_create_ml_candidate_params.rb | 14 | ||||
-rw-r--r-- | db/migrate/20220811092246_create_ml_candidate_metrics.rb | 16 | ||||
-rw-r--r-- | db/migrate/20220811092251_add_ml_candidates_reference_to_experiment.rb | 15 | ||||
-rw-r--r-- | db/migrate/20220811092253_add_ml_experiments_reference_to_project.rb | 15 | ||||
-rw-r--r-- | db/schema_migrations/20220811092243 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20220811092244 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20220811092245 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20220811092246 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20220811092251 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20220811092253 | 1 | ||||
-rw-r--r-- | db/structure.sql | 131 |
17 files changed, 271 insertions, 0 deletions
diff --git a/db/docs/ml_candidate_metrics.yml b/db/docs/ml_candidate_metrics.yml new file mode 100644 index 00000000000..b0d9ed13489 --- /dev/null +++ b/db/docs/ml_candidate_metrics.yml @@ -0,0 +1,10 @@ +--- +table_name: ml_candidate_metrics +classes: + - Ml::CandidateMetric +feature_categories: + - mlops + - incubation +description: Metrics recorded for a Machine Learning model candidate +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95168 +milestone: '15.4' diff --git a/db/docs/ml_candidate_params.yml b/db/docs/ml_candidate_params.yml new file mode 100644 index 00000000000..01903b66108 --- /dev/null +++ b/db/docs/ml_candidate_params.yml @@ -0,0 +1,10 @@ +--- +table_name: ml_candidate_params +classes: + - Ml::CandidateParams +feature_categories: + - mlops + - incubation +description: Configuration parameters recorded for a Machine Learning model candidate +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95168 +milestone: '15.4' diff --git a/db/docs/ml_candidates.yml b/db/docs/ml_candidates.yml new file mode 100644 index 00000000000..c1f7f622350 --- /dev/null +++ b/db/docs/ml_candidates.yml @@ -0,0 +1,10 @@ +--- +table_name: ml_candidates +classes: + - Ml::Candidate +feature_categories: + - mlops + - incubation +description: A Model Candidate is a record of the results on training a model on some configuration +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95168 +milestone: '15.4' diff --git a/db/docs/ml_experiments.yml b/db/docs/ml_experiments.yml new file mode 100644 index 00000000000..ea5edc9569c --- /dev/null +++ b/db/docs/ml_experiments.yml @@ -0,0 +1,10 @@ +--- +table_name: ml_experiments +classes: + - Ml::Experiment +feature_categories: + - mlops + - incubation +description: A Machine Learning Experiments groups many Model Candidates +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/95168 +milestone: '15.4' diff --git a/db/migrate/20220811092243_create_ml_experiments.rb b/db/migrate/20220811092243_create_ml_experiments.rb new file mode 100644 index 00000000000..a357d62133c --- /dev/null +++ b/db/migrate/20220811092243_create_ml_experiments.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class CreateMlExperiments < Gitlab::Database::Migration[2.0] + enable_lock_retries! + + def change + create_table :ml_experiments do |t| + t.timestamps_with_timezone null: false + t.bigint :iid, null: false + t.bigint :project_id, null: false + t.references :user, foreign_key: true, index: true, on_delete: :nullify + t.text :name, limit: 255, null: false + + t.index [:project_id, :iid], unique: true + t.index [:project_id, :name], unique: true + end + end +end diff --git a/db/migrate/20220811092244_create_ml_candidates.rb b/db/migrate/20220811092244_create_ml_candidates.rb new file mode 100644 index 00000000000..fe9fc293b03 --- /dev/null +++ b/db/migrate/20220811092244_create_ml_candidates.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class CreateMlCandidates < Gitlab::Database::Migration[2.0] + enable_lock_retries! + + def change + create_table :ml_candidates do |t| + t.timestamps_with_timezone null: false + t.uuid :iid, null: false + t.bigint :experiment_id, null: false + t.references :user, foreign_key: true, index: true, on_delete: :nullify + + t.index [:experiment_id, :iid], unique: true + end + end +end diff --git a/db/migrate/20220811092245_create_ml_candidate_params.rb b/db/migrate/20220811092245_create_ml_candidate_params.rb new file mode 100644 index 00000000000..55fc1cbe7af --- /dev/null +++ b/db/migrate/20220811092245_create_ml_candidate_params.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class CreateMlCandidateParams < Gitlab::Database::Migration[2.0] + def change + create_table :ml_candidate_params do |t| + t.timestamps_with_timezone null: false + t.references :candidate, + foreign_key: { to_table: :ml_candidates }, + index: true + t.text :name, limit: 250, null: false + t.text :value, limit: 250, null: false + end + end +end diff --git a/db/migrate/20220811092246_create_ml_candidate_metrics.rb b/db/migrate/20220811092246_create_ml_candidate_metrics.rb new file mode 100644 index 00000000000..a4d417f270e --- /dev/null +++ b/db/migrate/20220811092246_create_ml_candidate_metrics.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class CreateMlCandidateMetrics < Gitlab::Database::Migration[2.0] + def change + create_table :ml_candidate_metrics do |t| + t.timestamps_with_timezone null: false + t.references :candidate, + foreign_key: { to_table: :ml_candidates }, + index: true + t.float :value + t.integer :step + t.binary :is_nan + t.text :name, limit: 250, null: false + end + end +end diff --git a/db/migrate/20220811092251_add_ml_candidates_reference_to_experiment.rb b/db/migrate/20220811092251_add_ml_candidates_reference_to_experiment.rb new file mode 100644 index 00000000000..a3be644552c --- /dev/null +++ b/db/migrate/20220811092251_add_ml_candidates_reference_to_experiment.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddMlCandidatesReferenceToExperiment < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :ml_candidates, :ml_experiments, column: :experiment_id + end + + def down + with_lock_retries do + remove_foreign_key :ml_candidates, column: :experiment_id + end + end +end diff --git a/db/migrate/20220811092253_add_ml_experiments_reference_to_project.rb b/db/migrate/20220811092253_add_ml_experiments_reference_to_project.rb new file mode 100644 index 00000000000..4fd832dfe14 --- /dev/null +++ b/db/migrate/20220811092253_add_ml_experiments_reference_to_project.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class AddMlExperimentsReferenceToProject < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :ml_experiments, :projects, column: :project_id, on_delete: :cascade + end + + def down + with_lock_retries do + remove_foreign_key :ml_experiments, column: :project_id + end + end +end diff --git a/db/schema_migrations/20220811092243 b/db/schema_migrations/20220811092243 new file mode 100644 index 00000000000..6640e5f1a65 --- /dev/null +++ b/db/schema_migrations/20220811092243 @@ -0,0 +1 @@ +211eda22a78d14aaaf86345d3e33b852ba22a7dc9e41d9d683d58f162a7bdcc7
\ No newline at end of file diff --git a/db/schema_migrations/20220811092244 b/db/schema_migrations/20220811092244 new file mode 100644 index 00000000000..824d936a09c --- /dev/null +++ b/db/schema_migrations/20220811092244 @@ -0,0 +1 @@ +f871847fbd494e31f13cf2fb87a1b8e9fc47c44e7f0ec9cf37f2084d19b9bf5f
\ No newline at end of file diff --git a/db/schema_migrations/20220811092245 b/db/schema_migrations/20220811092245 new file mode 100644 index 00000000000..09bd431d928 --- /dev/null +++ b/db/schema_migrations/20220811092245 @@ -0,0 +1 @@ +0c856ce8170e4b864578f1bcb89d8930d8c1952e92356965a98e057521456968
\ No newline at end of file diff --git a/db/schema_migrations/20220811092246 b/db/schema_migrations/20220811092246 new file mode 100644 index 00000000000..64d3153b833 --- /dev/null +++ b/db/schema_migrations/20220811092246 @@ -0,0 +1 @@ +17bcb2fddd6331cbcec505e8094d1a400b7c3fd8b18897697aa9868689147cd7
\ No newline at end of file diff --git a/db/schema_migrations/20220811092251 b/db/schema_migrations/20220811092251 new file mode 100644 index 00000000000..61e2afaa74a --- /dev/null +++ b/db/schema_migrations/20220811092251 @@ -0,0 +1 @@ +4ea4bc7e6f88561553b19c7bf4992561772506cf532cf569241a536f69e19b7f
\ No newline at end of file diff --git a/db/schema_migrations/20220811092253 b/db/schema_migrations/20220811092253 new file mode 100644 index 00000000000..fc8ad6918e9 --- /dev/null +++ b/db/schema_migrations/20220811092253 @@ -0,0 +1 @@ +6a6eed069e051786a925b40469e7b53a563f99f0c6bfb810058511d3de8b0923
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index c2276aebc87..b055d831ce6 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -17596,6 +17596,85 @@ CREATE SEQUENCE milestones_id_seq ALTER SEQUENCE milestones_id_seq OWNED BY milestones.id; +CREATE TABLE ml_candidate_metrics ( + id bigint NOT NULL, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + candidate_id bigint, + value double precision, + step integer, + is_nan bytea, + name text NOT NULL, + CONSTRAINT check_3bb4a3fbd9 CHECK ((char_length(name) <= 250)) +); + +CREATE SEQUENCE ml_candidate_metrics_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE ml_candidate_metrics_id_seq OWNED BY ml_candidate_metrics.id; + +CREATE TABLE ml_candidate_params ( + id bigint NOT NULL, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + candidate_id bigint, + name text NOT NULL, + value text NOT NULL, + CONSTRAINT check_093034d049 CHECK ((char_length(name) <= 250)), + CONSTRAINT check_28a3c29e43 CHECK ((char_length(value) <= 250)) +); + +CREATE SEQUENCE ml_candidate_params_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE ml_candidate_params_id_seq OWNED BY ml_candidate_params.id; + +CREATE TABLE ml_candidates ( + id bigint NOT NULL, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + iid uuid NOT NULL, + experiment_id bigint NOT NULL, + user_id bigint +); + +CREATE SEQUENCE ml_candidates_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE ml_candidates_id_seq OWNED BY ml_candidates.id; + +CREATE TABLE ml_experiments ( + id bigint NOT NULL, + created_at timestamp with time zone NOT NULL, + updated_at timestamp with time zone NOT NULL, + iid bigint NOT NULL, + project_id bigint NOT NULL, + user_id bigint, + name text NOT NULL, + CONSTRAINT check_ee07a0be2c CHECK ((char_length(name) <= 255)) +); + +CREATE SEQUENCE ml_experiments_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE ml_experiments_id_seq OWNED BY ml_experiments.id; + CREATE TABLE namespace_admin_notes ( id bigint NOT NULL, created_at timestamp with time zone NOT NULL, @@ -23468,6 +23547,14 @@ ALTER TABLE ONLY metrics_users_starred_dashboards ALTER COLUMN id SET DEFAULT ne ALTER TABLE ONLY milestones ALTER COLUMN id SET DEFAULT nextval('milestones_id_seq'::regclass); +ALTER TABLE ONLY ml_candidate_metrics ALTER COLUMN id SET DEFAULT nextval('ml_candidate_metrics_id_seq'::regclass); + +ALTER TABLE ONLY ml_candidate_params ALTER COLUMN id SET DEFAULT nextval('ml_candidate_params_id_seq'::regclass); + +ALTER TABLE ONLY ml_candidates ALTER COLUMN id SET DEFAULT nextval('ml_candidates_id_seq'::regclass); + +ALTER TABLE ONLY ml_experiments ALTER COLUMN id SET DEFAULT nextval('ml_experiments_id_seq'::regclass); + ALTER TABLE ONLY namespace_admin_notes ALTER COLUMN id SET DEFAULT nextval('namespace_admin_notes_id_seq'::regclass); ALTER TABLE ONLY namespace_bans ALTER COLUMN id SET DEFAULT nextval('namespace_bans_id_seq'::regclass); @@ -25479,6 +25566,18 @@ ALTER TABLE ONLY milestone_releases ALTER TABLE ONLY milestones ADD CONSTRAINT milestones_pkey PRIMARY KEY (id); +ALTER TABLE ONLY ml_candidate_metrics + ADD CONSTRAINT ml_candidate_metrics_pkey PRIMARY KEY (id); + +ALTER TABLE ONLY ml_candidate_params + ADD CONSTRAINT ml_candidate_params_pkey PRIMARY KEY (id); + +ALTER TABLE ONLY ml_candidates + ADD CONSTRAINT ml_candidates_pkey PRIMARY KEY (id); + +ALTER TABLE ONLY ml_experiments + ADD CONSTRAINT ml_experiments_pkey PRIMARY KEY (id); + ALTER TABLE ONLY namespace_admin_notes ADD CONSTRAINT namespace_admin_notes_pkey PRIMARY KEY (id); @@ -29037,6 +29136,20 @@ CREATE INDEX index_milestones_on_title_trigram ON milestones USING gin (title gi CREATE INDEX index_mirror_data_non_scheduled_or_started ON project_mirror_data USING btree (next_execution_timestamp, retry_count) WHERE ((status)::text <> ALL ('{scheduled,started}'::text[])); +CREATE INDEX index_ml_candidate_metrics_on_candidate_id ON ml_candidate_metrics USING btree (candidate_id); + +CREATE INDEX index_ml_candidate_params_on_candidate_id ON ml_candidate_params USING btree (candidate_id); + +CREATE UNIQUE INDEX index_ml_candidates_on_experiment_id_and_iid ON ml_candidates USING btree (experiment_id, iid); + +CREATE INDEX index_ml_candidates_on_user_id ON ml_candidates USING btree (user_id); + +CREATE UNIQUE INDEX index_ml_experiments_on_project_id_and_iid ON ml_experiments USING btree (project_id, iid); + +CREATE UNIQUE INDEX index_ml_experiments_on_project_id_and_name ON ml_experiments USING btree (project_id, name); + +CREATE INDEX index_ml_experiments_on_user_id ON ml_experiments USING btree (user_id); + CREATE UNIQUE INDEX index_mr_blocks_on_blocking_and_blocked_mr_ids ON merge_request_blocks USING btree (blocking_merge_request_id, blocked_merge_request_id); CREATE INDEX index_mr_cleanup_schedules_timestamps_status ON merge_request_cleanup_schedules USING btree (scheduled_at) WHERE ((completed_at IS NULL) AND (status = 0)); @@ -32180,6 +32293,9 @@ ALTER TABLE ONLY merge_request_metrics ALTER TABLE ONLY vulnerability_feedback ADD CONSTRAINT fk_563ff1912e FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE SET NULL; +ALTER TABLE ONLY ml_candidates + ADD CONSTRAINT fk_56d6ed4d3d FOREIGN KEY (experiment_id) REFERENCES ml_experiments(id) ON DELETE CASCADE; + ALTER TABLE ONLY deploy_keys_projects ADD CONSTRAINT fk_58a901ca7e FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; @@ -32477,6 +32593,9 @@ ALTER TABLE ONLY member_tasks ALTER TABLE ONLY merge_requests ADD CONSTRAINT fk_ad525e1f87 FOREIGN KEY (merge_user_id) REFERENCES users(id) ON DELETE SET NULL; +ALTER TABLE ONLY ml_experiments + ADD CONSTRAINT fk_ad89c59858 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; @@ -32987,6 +33106,9 @@ ALTER TABLE ONLY vulnerability_user_mentions ALTER TABLE ONLY packages_debian_file_metadata ADD CONSTRAINT fk_rails_1ae85be112 FOREIGN KEY (package_file_id) REFERENCES packages_package_files(id) ON DELETE CASCADE; +ALTER TABLE ONLY ml_candidates + ADD CONSTRAINT fk_rails_1b37441fe5 FOREIGN KEY (user_id) REFERENCES users(id); + ALTER TABLE ONLY issuable_slas ADD CONSTRAINT fk_rails_1b8768cd63 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE; @@ -33014,6 +33136,9 @@ ALTER TABLE ONLY geo_repository_created_events ALTER TABLE ONLY external_status_checks ADD CONSTRAINT fk_rails_1f5a8aa809 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; +ALTER TABLE ONLY ml_experiments + ADD CONSTRAINT fk_rails_1fbc5e001f FOREIGN KEY (user_id) REFERENCES users(id); + ALTER TABLE ONLY dora_daily_metrics ADD CONSTRAINT fk_rails_1fd07aff6f FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE CASCADE; @@ -34145,6 +34270,9 @@ ALTER TABLE ONLY alert_management_alert_assignees ALTER TABLE ONLY geo_hashed_storage_attachments_events ADD CONSTRAINT fk_rails_d496b088e9 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; +ALTER TABLE ONLY ml_candidate_params + ADD CONSTRAINT fk_rails_d4a51d1185 FOREIGN KEY (candidate_id) REFERENCES ml_candidates(id); + ALTER TABLE ONLY merge_request_reviewers ADD CONSTRAINT fk_rails_d9fec24b9d FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE; @@ -34292,6 +34420,9 @@ ALTER TABLE ONLY project_relation_exports ALTER TABLE ONLY label_priorities ADD CONSTRAINT fk_rails_ef916d14fa FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; +ALTER TABLE ONLY ml_candidate_metrics + ADD CONSTRAINT fk_rails_efb613a25a FOREIGN KEY (candidate_id) REFERENCES ml_candidates(id); + ALTER TABLE ONLY fork_network_members ADD CONSTRAINT fk_rails_efccadc4ec FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; |