diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20201123161611_add_provisioned_by_group_to_user_details.rb | 29 | ||||
-rw-r--r-- | db/migrate/20201201163227_add_finding_uuid_to_vulnerability_feedback.rb | 10 | ||||
-rw-r--r-- | db/migrate/20201202081429_update_internal_ids_last_value_for_epics.rb | 27 | ||||
-rw-r--r-- | db/schema_migrations/20201123161611 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20201201163227 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20201202081429 | 1 | ||||
-rw-r--r-- | db/structure.sql | 9 |
7 files changed, 77 insertions, 1 deletions
diff --git a/db/migrate/20201123161611_add_provisioned_by_group_to_user_details.rb b/db/migrate/20201123161611_add_provisioned_by_group_to_user_details.rb new file mode 100644 index 00000000000..6e4d0e84509 --- /dev/null +++ b/db/migrate/20201123161611_add_provisioned_by_group_to_user_details.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class AddProvisionedByGroupToUserDetails < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_user_details_on_provisioned_by_group_id' + + disable_ddl_transaction! + + def up + unless column_exists?(:user_details, :provisioned_by_group_id) + with_lock_retries { add_column(:user_details, :provisioned_by_group_id, :integer, limit: 8) } + end + + add_concurrent_index :user_details, :provisioned_by_group_id, name: INDEX_NAME + add_concurrent_foreign_key :user_details, :namespaces, column: :provisioned_by_group_id, on_delete: :nullify + end + + def down + with_lock_retries { remove_foreign_key_without_error :user_details, column: :provisioned_by_group_id } + + remove_concurrent_index_by_name :user_details, INDEX_NAME + + if column_exists?(:user_details, :provisioned_by_group_id) + with_lock_retries { remove_column(:user_details, :provisioned_by_group_id) } + end + end +end diff --git a/db/migrate/20201201163227_add_finding_uuid_to_vulnerability_feedback.rb b/db/migrate/20201201163227_add_finding_uuid_to_vulnerability_feedback.rb new file mode 100644 index 00000000000..a2e13806000 --- /dev/null +++ b/db/migrate/20201201163227_add_finding_uuid_to_vulnerability_feedback.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class AddFindingUuidToVulnerabilityFeedback < ActiveRecord::Migration[6.0] + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def change + add_column :vulnerability_feedback, :finding_uuid, :uuid + end +end diff --git a/db/migrate/20201202081429_update_internal_ids_last_value_for_epics.rb b/db/migrate/20201202081429_update_internal_ids_last_value_for_epics.rb new file mode 100644 index 00000000000..7f6aefde7da --- /dev/null +++ b/db/migrate/20201202081429_update_internal_ids_last_value_for_epics.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class UpdateInternalIdsLastValueForEpics < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def up + ApplicationRecord.connection.execute(<<-SQL.squish) + UPDATE internal_ids + SET last_value = epics_max_iids.maximum_iid + FROM + ( + SELECT + MAX(epics.iid) AS maximum_iid, + epics.group_id AS epics_group_id + FROM epics + GROUP BY epics.group_id + ) epics_max_iids + WHERE internal_ids.last_value < epics_max_iids.maximum_iid + AND namespace_id = epics_max_iids.epics_group_id + AND internal_ids.usage = 4 + SQL + end + + def down + # no-op + end +end diff --git a/db/schema_migrations/20201123161611 b/db/schema_migrations/20201123161611 new file mode 100644 index 00000000000..bcd28f2b4da --- /dev/null +++ b/db/schema_migrations/20201123161611 @@ -0,0 +1 @@ +9d69938cda6db1510ed17d087cc1a582af1e5482d65e4fb457e34011e09c3469
\ No newline at end of file diff --git a/db/schema_migrations/20201201163227 b/db/schema_migrations/20201201163227 new file mode 100644 index 00000000000..0366850ee2f --- /dev/null +++ b/db/schema_migrations/20201201163227 @@ -0,0 +1 @@ +cc978ac56ed177575706436c52125b51915dff97a20ed47ae0c7b16caa837313
\ No newline at end of file diff --git a/db/schema_migrations/20201202081429 b/db/schema_migrations/20201202081429 new file mode 100644 index 00000000000..2a8e170c0ff --- /dev/null +++ b/db/schema_migrations/20201202081429 @@ -0,0 +1 @@ +cbc6bfa122167e9a46edaa14351a73eeb10586fa0eb82f231c792384c9d7986c
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 2a0b85144f2..94f92b2af16 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -16998,6 +16998,7 @@ CREATE TABLE user_details ( cached_markdown_version integer, webauthn_xid text, other_role text, + provisioned_by_group_id bigint, CONSTRAINT check_245664af82 CHECK ((char_length(webauthn_xid) <= 100)), CONSTRAINT check_b132136b01 CHECK ((char_length(other_role) <= 100)) ); @@ -17376,7 +17377,8 @@ CREATE TABLE vulnerability_feedback ( merge_request_id integer, comment_author_id integer, comment text, - comment_timestamp timestamp with time zone + comment_timestamp timestamp with time zone, + finding_uuid uuid ); CREATE SEQUENCE vulnerability_feedback_id_seq @@ -22472,6 +22474,8 @@ CREATE INDEX index_user_custom_attributes_on_key_and_value ON user_custom_attrib CREATE UNIQUE INDEX index_user_custom_attributes_on_user_id_and_key ON user_custom_attributes USING btree (user_id, key); +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_highest_roles_on_user_id_and_highest_access_level ON user_highest_roles USING btree (user_id, highest_access_level); @@ -23067,6 +23071,9 @@ ALTER TABLE ONLY project_features ALTER TABLE ONLY ci_pipelines ADD CONSTRAINT fk_190998ef09 FOREIGN KEY (external_pull_request_id) REFERENCES external_pull_requests(id) ON DELETE SET NULL; +ALTER TABLE ONLY user_details + ADD CONSTRAINT fk_190e4fcc88 FOREIGN KEY (provisioned_by_group_id) REFERENCES namespaces(id) ON DELETE SET NULL; + ALTER TABLE ONLY vulnerabilities ADD CONSTRAINT fk_1d37cddf91 FOREIGN KEY (epic_id) REFERENCES epics(id) ON DELETE SET NULL; |