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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-30 03:08:48 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-30 03:08:48 +0300
commitf15be95ca1b92d0f37d926e909f2d805118ced29 (patch)
tree436618b9acece35b77a55266c0dc13d3f5a2cf81 /db
parenta5c89610f3a29118fd7cb1de80ad1f8f0be5363e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20220726154012_ensure_sbom_occurrences_is_empty.rb18
-rw-r--r--db/migrate/20220726154013_add_component_id_to_sbom_occurrences.rb17
-rw-r--r--db/migrate/20220726154014_add_index_to_sbom_occurrences_component_id.rb15
-rw-r--r--db/migrate/20220726154015_add_component_foreign_key_to_sbom_occurrences.rb18
-rw-r--r--db/migrate/20220726154016_make_component_version_nullable.rb9
-rw-r--r--db/schema_migrations/202207261540121
-rw-r--r--db/schema_migrations/202207261540131
-rw-r--r--db/schema_migrations/202207261540141
-rw-r--r--db/schema_migrations/202207261540151
-rw-r--r--db/schema_migrations/202207261540161
-rw-r--r--db/structure.sql10
11 files changed, 90 insertions, 2 deletions
diff --git a/db/migrate/20220726154012_ensure_sbom_occurrences_is_empty.rb b/db/migrate/20220726154012_ensure_sbom_occurrences_is_empty.rb
new file mode 100644
index 00000000000..18c48d1202d
--- /dev/null
+++ b/db/migrate/20220726154012_ensure_sbom_occurrences_is_empty.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class EnsureSbomOccurrencesIsEmpty < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ # Ensure that the sbom_occurrences table is empty to ensure that the
+ # following migration adding a not-null column succeeds.
+ # The code which creates records in this table has not been implemented yet.
+ execute('DELETE FROM sbom_occurrences')
+ end
+
+ def down
+ # no-op
+ end
+end
diff --git a/db/migrate/20220726154013_add_component_id_to_sbom_occurrences.rb b/db/migrate/20220726154013_add_component_id_to_sbom_occurrences.rb
new file mode 100644
index 00000000000..9631dadc938
--- /dev/null
+++ b/db/migrate/20220726154013_add_component_id_to_sbom_occurrences.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddComponentIdToSbomOccurrences < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def up
+ # Code using this table has not been implemented yet.
+ # The migration prior to this one ensures that it is empty.
+ # rubocop:disable Rails/NotNullColumn
+ add_column :sbom_occurrences, :component_id, :bigint, null: false
+ # rubocop:enable Rails/NotNullColumn
+ end
+
+ def down
+ remove_column :sbom_occurrences, :component_id
+ end
+end
diff --git a/db/migrate/20220726154014_add_index_to_sbom_occurrences_component_id.rb b/db/migrate/20220726154014_add_index_to_sbom_occurrences_component_id.rb
new file mode 100644
index 00000000000..ed944fd0b90
--- /dev/null
+++ b/db/migrate/20220726154014_add_index_to_sbom_occurrences_component_id.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class AddIndexToSbomOccurrencesComponentId < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = "index_sbom_occurrences_on_component_id"
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :sbom_occurrences, :component_id, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :sbom_occurrences, name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20220726154015_add_component_foreign_key_to_sbom_occurrences.rb b/db/migrate/20220726154015_add_component_foreign_key_to_sbom_occurrences.rb
new file mode 100644
index 00000000000..1c7341c4aa2
--- /dev/null
+++ b/db/migrate/20220726154015_add_component_foreign_key_to_sbom_occurrences.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddComponentForeignKeyToSbomOccurrences < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :sbom_occurrences,
+ :sbom_components,
+ column: :component_id,
+ on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :sbom_occurrences, column: :component_id
+ end
+ end
+end
diff --git a/db/migrate/20220726154016_make_component_version_nullable.rb b/db/migrate/20220726154016_make_component_version_nullable.rb
new file mode 100644
index 00000000000..8619b9dad12
--- /dev/null
+++ b/db/migrate/20220726154016_make_component_version_nullable.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class MakeComponentVersionNullable < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def change
+ change_column_null :sbom_occurrences, :component_version_id, true
+ end
+end
diff --git a/db/schema_migrations/20220726154012 b/db/schema_migrations/20220726154012
new file mode 100644
index 00000000000..b3e54480054
--- /dev/null
+++ b/db/schema_migrations/20220726154012
@@ -0,0 +1 @@
+6db09c05e52a9397eff77c56ab54886cd5b1ea5235425cbc83f865352dd75706 \ No newline at end of file
diff --git a/db/schema_migrations/20220726154013 b/db/schema_migrations/20220726154013
new file mode 100644
index 00000000000..6ef0bc248bb
--- /dev/null
+++ b/db/schema_migrations/20220726154013
@@ -0,0 +1 @@
+e079df21e69a855a3dc6c306e14796dacfabacc97632b859481009808a7ce133 \ No newline at end of file
diff --git a/db/schema_migrations/20220726154014 b/db/schema_migrations/20220726154014
new file mode 100644
index 00000000000..1991af185e8
--- /dev/null
+++ b/db/schema_migrations/20220726154014
@@ -0,0 +1 @@
+22c29639048e83f926b5ed2a44a14638fa70cba01f7f11a97f97ec321ae9173c \ No newline at end of file
diff --git a/db/schema_migrations/20220726154015 b/db/schema_migrations/20220726154015
new file mode 100644
index 00000000000..1eb661be563
--- /dev/null
+++ b/db/schema_migrations/20220726154015
@@ -0,0 +1 @@
+4c8d8356b977f875540bb931bfe03c811de17223bd76632ba65af53b7e227b08 \ No newline at end of file
diff --git a/db/schema_migrations/20220726154016 b/db/schema_migrations/20220726154016
new file mode 100644
index 00000000000..1df82964d21
--- /dev/null
+++ b/db/schema_migrations/20220726154016
@@ -0,0 +1 @@
+87bd0e2a2d0a9a8a45ce177ed847a15d2f015b155a1a47cd8fcf6ea00713b98c \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index ff56ae202e8..0c6b484174d 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -20606,11 +20606,12 @@ CREATE TABLE sbom_occurrences (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
- component_version_id bigint NOT NULL,
+ component_version_id bigint,
project_id bigint NOT NULL,
pipeline_id bigint,
source_id bigint,
- commit_sha bytea NOT NULL
+ commit_sha bytea NOT NULL,
+ component_id bigint NOT NULL
);
CREATE SEQUENCE sbom_occurrences_id_seq
@@ -29662,6 +29663,8 @@ CREATE UNIQUE INDEX index_saved_replies_on_name_text_pattern_ops ON saved_replie
CREATE INDEX index_sbom_component_versions_on_component_id ON sbom_component_versions USING btree (component_id);
+CREATE INDEX index_sbom_occurrences_on_component_id ON sbom_occurrences USING btree (component_id);
+
CREATE INDEX index_sbom_occurrences_on_component_version_id ON sbom_occurrences USING btree (component_version_id);
CREATE INDEX index_sbom_occurrences_on_pipeline_id ON sbom_occurrences USING btree (pipeline_id);
@@ -32494,6 +32497,9 @@ ALTER TABLE ONLY ci_pipelines
ALTER TABLE ONLY system_note_metadata
ADD CONSTRAINT fk_d83a918cb1 FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE;
+ALTER TABLE ONLY sbom_occurrences
+ ADD CONSTRAINT fk_d857c6edc1 FOREIGN KEY (component_id) REFERENCES sbom_components(id) ON DELETE CASCADE;
+
ALTER TABLE ONLY todos
ADD CONSTRAINT fk_d94154aa95 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;