Commit f524c3a5 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'add-inherit-from-to-services' into 'master'

Add 'inherit_from_id' column to services table

See merge request gitlab-org/gitlab!31320
parents 7020f8fe d3755ac7
---
title: Add inherit_from_id column to services table
merge_request: 31320
author:
type: other
# frozen_string_literal: true
class AddInheritFromToServices < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :services, :inherit_from_id, :bigint
end
end
# frozen_string_literal: true
class AddIndexInheritFromIdToServices < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :services, :inherit_from_id
add_concurrent_foreign_key :services, :services, column: :inherit_from_id, on_delete: :nullify
end
def down
remove_foreign_key_if_exists :services, column: :inherit_from_id
remove_concurrent_index :services, :inherit_from_id
end
end
......@@ -6058,7 +6058,8 @@ CREATE TABLE public.services (
comment_on_event_enabled boolean DEFAULT true NOT NULL,
template boolean DEFAULT false,
instance boolean DEFAULT false NOT NULL,
comment_detail smallint
comment_detail smallint,
inherit_from_id bigint
);
CREATE SEQUENCE public.services_id_seq
......@@ -10570,6 +10571,8 @@ CREATE INDEX index_serverless_domain_cluster_on_pages_domain_id ON public.server
CREATE INDEX index_service_desk_enabled_projects_on_id_creator_id_created_at ON public.projects USING btree (id, creator_id, created_at) WHERE (service_desk_enabled = true);
CREATE INDEX index_services_on_inherit_from_id ON public.services USING btree (inherit_from_id);
CREATE INDEX index_services_on_project_id_and_type ON public.services USING btree (project_id, type);
CREATE INDEX index_services_on_template ON public.services USING btree (template);
......@@ -11237,6 +11240,9 @@ ALTER TABLE ONLY public.merge_request_diffs
ALTER TABLE ONLY public.ci_pipelines
ADD CONSTRAINT fk_86635dbd80 FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.services
ADD CONSTRAINT fk_868a8e7ad6 FOREIGN KEY (inherit_from_id) REFERENCES public.services(id) ON DELETE SET NULL;
ALTER TABLE ONLY public.geo_event_log
ADD CONSTRAINT fk_86c84214ec FOREIGN KEY (repository_renamed_event_id) REFERENCES public.geo_repository_renamed_events(id) ON DELETE CASCADE;
......@@ -13797,6 +13803,8 @@ COPY "schema_migrations" (version) FROM STDIN;
20200507221434
20200508091106
20200511092714
20200511115430
20200511115431
20200511121549
20200511121610
20200511121620
......
......@@ -261,8 +261,9 @@ excluded_attributes:
- :token
- :token_encrypted
services:
- :template
- :inherit_from_id
- :instance
- :template
error_tracking_setting:
- :encrypted_token
- :encrypted_token_iv
......
......@@ -14,9 +14,9 @@ describe 'Database schema' do
IGNORED_FK_COLUMNS = {
abuse_reports: %w[reporter_id user_id],
application_settings: %w[performance_bar_allowed_group_id slack_app_id snowplow_app_id eks_account_id eks_access_key_id],
approvers: %w[target_id user_id],
approvals: %w[user_id],
approver_groups: %w[target_id],
approvers: %w[target_id user_id],
audit_events: %w[author_id entity_id],
award_emoji: %w[awardable_id user_id],
aws_roles: %w[role_external_id],
......@@ -29,12 +29,13 @@ describe 'Database schema' do
ci_trigger_requests: %w[commit_id],
cluster_providers_aws: %w[security_group_id vpc_id access_key_id],
cluster_providers_gcp: %w[gcp_project_id operation_id],
commit_user_mentions: %w[commit_id],
deploy_keys_projects: %w[deploy_key_id],
deployments: %w[deployable_id environment_id user_id],
draft_notes: %w[discussion_id commit_id],
emails: %w[user_id],
events: %w[target_id],
epics: %w[updated_by_id last_edited_by_id state_id],
events: %w[target_id],
forked_project_links: %w[forked_from_project_id],
geo_event_log: %w[hashed_storage_attachments_event_id],
geo_job_artifact_deleted_events: %w[job_artifact_id],
......@@ -44,14 +45,14 @@ describe 'Database schema' do
geo_repository_deleted_events: %w[project_id],
geo_upload_deleted_events: %w[upload_id model_id],
gitlab_subscription_histories: %w[gitlab_subscription_id hosted_plan_id namespace_id],
import_failures: %w[project_id],
identities: %w[user_id],
import_failures: %w[project_id],
issues: %w[last_edited_by_id state_id],
jira_tracker_data: %w[jira_issue_transition_id],
keys: %w[user_id],
label_links: %w[target_id],
lfs_objects_projects: %w[lfs_object_id project_id],
ldap_group_links: %w[group_id],
lfs_objects_projects: %w[lfs_object_id project_id],
members: %w[source_id created_by_id],
merge_requests: %w[last_edited_by_id state_id],
namespaces: %w[owner_id parent_id],
......@@ -68,10 +69,11 @@ describe 'Database schema' do
repository_languages: %w[programming_language_id],
routes: %w[source_id],
sent_notifications: %w[project_id noteable_id recipient_id commit_id in_reply_to_discussion_id],
slack_integrations: %w[team_id user_id],
snippets: %w[author_id],
spam_logs: %w[user_id],
subscriptions: %w[user_id subscribable_id],
slack_integrations: %w[team_id user_id],
suggestions: %w[commit_id],
taggings: %w[tag_id taggable_id tagger_id],
timelogs: %w[user_id],
todos: %w[target_id commit_id],
......@@ -81,9 +83,7 @@ describe 'Database schema' do
users_star_projects: %w[user_id],
vulnerability_identifiers: %w[external_id],
vulnerability_scanners: %w[external_id],
web_hooks: %w[service_id group_id],
suggestions: %w[commit_id],
commit_user_mentions: %w[commit_id]
web_hooks: %w[service_id group_id]
}.with_indifferent_access.freeze
context 'for table' do
......
......@@ -488,6 +488,7 @@ Service:
- confidential_note_events
- deployment_events
- description
- inherit_from_id
ProjectHook:
- id
- url
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment