Skip to content
Snippets Groups Projects
Commit 23a95b27 authored by Hunar Khanna's avatar Hunar Khanna
Browse files

Add table to support new group-agent authorization strategy for RD

Changelog: added
parent 03889419
No related branches found
No related tags found
1 merge request!145101BE: Add data store to support namespace-cluster agent mapping for RD
Showing
with 163 additions and 0 deletions
---
table_name: remote_development_namespace_cluster_agent_mappings
classes:
- RemoteDevelopment::RemoteDevelopmentNamespaceClusterAgentMapping
feature_categories:
- remote_development
description: This table records associations between Namespaces and Cluster Agents
as a part of supporting group-cluster agent association in the context of Remote
Development Workspaces
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/145101
milestone: '16.10'
gitlab_schema: gitlab_main_cell
allow_cross_joins:
- gitlab_main_clusterwide
allow_cross_transactions:
- gitlab_main_clusterwide
allow_cross_foreign_keys:
- gitlab_main_clusterwide
sharding_key:
namespace_id: namespaces
# frozen_string_literal: true
class CreateRdNamespaceClusterAgentMappingsTable < Gitlab::Database::Migration[2.2]
disable_ddl_transaction!
milestone '16.10'
TABLE_NAME = :remote_development_namespace_cluster_agent_mappings
UNIQUE_NAMESPACE_CLUSTER_AGENT_INDEX_NAME = "unique_namespace_cluster_agent_mappings_for_agent_association"
CLUSTER_AGENT_INDEX_NAME = "i_namespace_cluster_agent_mappings_on_cluster_agent_id"
CREATOR_ID_INDEX_NAME = "i_namespace_cluster_agent_mappings_on_creator_id"
def up
unless table_exists?(TABLE_NAME)
create_table TABLE_NAME do |t|
t.timestamps_with_timezone null: false
t.bigint :namespace_id, null: false
t.bigint :cluster_agent_id, null: false
t.bigint :creator_id, null: true
end
end
add_concurrent_index TABLE_NAME, [:namespace_id, :cluster_agent_id],
unique: true, name: UNIQUE_NAMESPACE_CLUSTER_AGENT_INDEX_NAME
# The indices below have been added for the sake of making cascade updates faster for the involved
# foreign key columns
add_concurrent_index TABLE_NAME, :cluster_agent_id, name: CLUSTER_AGENT_INDEX_NAME
add_concurrent_index TABLE_NAME, :creator_id, name: CREATOR_ID_INDEX_NAME
end
def down
drop_table TABLE_NAME
end
end
# frozen_string_literal: true
class AddNamespaceFkToNamespaceClusterAgentMappingsTable < Gitlab::Database::Migration[2.2]
disable_ddl_transaction!
milestone '16.10'
def up
add_concurrent_foreign_key :remote_development_namespace_cluster_agent_mappings,
:namespaces,
column: :namespace_id,
on_delete: :cascade
end
def down
with_lock_retries do
remove_foreign_key :remote_development_namespace_cluster_agent_mappings, column: :namespace_id
end
end
end
# frozen_string_literal: true
class AddClusterAgentFkToNamespaceClusterAgentMappingsTable < Gitlab::Database::Migration[2.2]
disable_ddl_transaction!
milestone '16.10'
def up
add_concurrent_foreign_key :remote_development_namespace_cluster_agent_mappings,
:cluster_agents,
column: :cluster_agent_id,
on_delete: :cascade
end
def down
with_lock_retries do
remove_foreign_key :remote_development_namespace_cluster_agent_mappings, column: :cluster_agent_id
end
end
end
# frozen_string_literal: true
class AddCreatorIdFkToNamespaceClusterAgentMappingsTable < Gitlab::Database::Migration[2.2]
disable_ddl_transaction!
milestone '16.10'
def up
add_concurrent_foreign_key :remote_development_namespace_cluster_agent_mappings,
:users,
column: :creator_id,
on_delete: :nullify
end
def down
with_lock_retries do
remove_foreign_key :remote_development_namespace_cluster_agent_mappings, column: :creator_id
end
end
end
d6f6a283172c84c63a26efe87ed69d41ea7425152e098eb961fcbf43fd4eabb9
\ No newline at end of file
3dee98896ef394e9b75c4eac304e1b756104fdda7d15b8d5d904886fc521d39a
\ No newline at end of file
38ae38b972e23603e7fe229f08529371e1372c4cf922a9cc98aa524198eaefae
\ No newline at end of file
43aec164f22afdc42ffd2e0896218e477786bc572baea30ecf448c36f3c003de
\ No newline at end of file
......@@ -14822,6 +14822,24 @@ CREATE SEQUENCE remote_development_agent_configs_id_seq
 
ALTER SEQUENCE remote_development_agent_configs_id_seq OWNED BY remote_development_agent_configs.id;
 
CREATE TABLE remote_development_namespace_cluster_agent_mappings (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
namespace_id bigint NOT NULL,
cluster_agent_id bigint NOT NULL,
creator_id bigint
);
CREATE SEQUENCE remote_development_namespace_cluster_agent_mappings_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE remote_development_namespace_cluster_agent_mappings_id_seq OWNED BY remote_development_namespace_cluster_agent_mappings.id;
CREATE TABLE remote_mirrors (
id integer NOT NULL,
project_id integer,
......@@ -19280,6 +19298,8 @@ ALTER TABLE ONLY releases ALTER COLUMN id SET DEFAULT nextval('releases_id_seq':
 
ALTER TABLE ONLY remote_development_agent_configs ALTER COLUMN id SET DEFAULT nextval('remote_development_agent_configs_id_seq'::regclass);
 
ALTER TABLE ONLY remote_development_namespace_cluster_agent_mappings ALTER COLUMN id SET DEFAULT nextval('remote_development_namespace_cluster_agent_mappings_id_seq'::regclass);
ALTER TABLE ONLY remote_mirrors ALTER COLUMN id SET DEFAULT nextval('remote_mirrors_id_seq'::regclass);
 
ALTER TABLE ONLY required_code_owners_sections ALTER COLUMN id SET DEFAULT nextval('required_code_owners_sections_id_seq'::regclass);
......@@ -21752,6 +21772,9 @@ ALTER TABLE ONLY releases
ALTER TABLE ONLY remote_development_agent_configs
ADD CONSTRAINT remote_development_agent_configs_pkey PRIMARY KEY (id);
 
ALTER TABLE ONLY remote_development_namespace_cluster_agent_mappings
ADD CONSTRAINT remote_development_namespace_cluster_agent_mappings_pkey PRIMARY KEY (id);
ALTER TABLE ONLY remote_mirrors
ADD CONSTRAINT remote_mirrors_pkey PRIMARY KEY (id);
 
......@@ -23438,6 +23461,10 @@ CREATE INDEX i_dast_profiles_tags_on_scanner_profiles_id ON dast_profiles_tags U
 
CREATE INDEX i_dast_scanner_profiles_tags_on_scanner_profiles_id ON dast_scanner_profiles_tags USING btree (dast_scanner_profile_id);
 
CREATE INDEX i_namespace_cluster_agent_mappings_on_cluster_agent_id ON remote_development_namespace_cluster_agent_mappings USING btree (cluster_agent_id);
CREATE INDEX i_namespace_cluster_agent_mappings_on_creator_id ON remote_development_namespace_cluster_agent_mappings USING btree (creator_id);
CREATE UNIQUE INDEX i_packages_unique_project_id_package_type_package_name_pattern ON packages_protection_rules USING btree (project_id, package_type, package_name_pattern);
 
CREATE INDEX i_pkgs_deb_file_meta_on_updated_at_package_file_id_when_unknown ON packages_debian_file_metadata USING btree (updated_at, package_file_id) WHERE (file_type = 1);
......@@ -27574,6 +27601,8 @@ CREATE UNIQUE INDEX unique_merge_request_metrics_by_merge_request_id ON merge_re
 
CREATE INDEX unique_ml_model_versions_on_model_id_and_id ON ml_model_versions USING btree (model_id, id DESC);
 
CREATE UNIQUE INDEX unique_namespace_cluster_agent_mappings_for_agent_association ON remote_development_namespace_cluster_agent_mappings USING btree (namespace_id, cluster_agent_id);
CREATE UNIQUE INDEX unique_organizations_on_path_case_insensitive ON organizations USING btree (lower(path));
 
CREATE UNIQUE INDEX unique_packages_project_id_and_name_and_version_when_debian ON packages_packages USING btree (project_id, name, version) WHERE ((package_type = 9) AND (status <> 4));
......@@ -29295,6 +29324,9 @@ ALTER TABLE ONLY approval_group_rules_protected_branches
ALTER TABLE ONLY issue_customer_relations_contacts
ADD CONSTRAINT fk_0c0037f723 FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
 
ALTER TABLE ONLY remote_development_namespace_cluster_agent_mappings
ADD CONSTRAINT fk_0c483ecb9d FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
ALTER TABLE ONLY ssh_signatures
ADD CONSTRAINT fk_0c83baaa5f FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;
 
......@@ -29316,6 +29348,9 @@ ALTER TABLE ONLY project_pages_metadata
ALTER TABLE ONLY group_deletion_schedules
ADD CONSTRAINT fk_11e3ebfcdd FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
 
ALTER TABLE ONLY remote_development_namespace_cluster_agent_mappings
ADD CONSTRAINT fk_124d8167c5 FOREIGN KEY (creator_id) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE ONLY member_approvals
ADD CONSTRAINT fk_1383c72212 FOREIGN KEY (member_namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
 
......@@ -30096,6 +30131,9 @@ ALTER TABLE ONLY ci_sources_pipelines
ALTER TABLE ONLY packages_maven_metadata
ADD CONSTRAINT fk_be88aed360 FOREIGN KEY (package_id) REFERENCES packages_packages(id) ON DELETE CASCADE;
 
ALTER TABLE ONLY remote_development_namespace_cluster_agent_mappings
ADD CONSTRAINT fk_be8e9c740f FOREIGN KEY (cluster_agent_id) REFERENCES cluster_agents(id) ON DELETE CASCADE;
ALTER TABLE ONLY zoekt_indices
ADD CONSTRAINT fk_bf205d4773 FOREIGN KEY (zoekt_enabled_namespace_id) REFERENCES zoekt_enabled_namespaces(id) ON DELETE SET NULL;
 
# frozen_string_literal: true
module RemoteDevelopment
class RemoteDevelopmentNamespaceClusterAgentMapping < ApplicationRecord
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment