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>2021-02-17 03:09:19 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-17 03:09:19 +0300
commit668e319631855d6d9396a203ded1fa5bcb986f1f (patch)
tree1cf0af29731df8b276a29fa82a5f419da6d06d18 /db
parent44e10d208a967d496b4602732b421c704f09201a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20210120180956_extend_index_on_ci_builds_metadata.rb40
-rw-r--r--db/migrate/20210216135504_add_created_by_to_cluster_agent.rb27
-rw-r--r--db/schema_migrations/202101201809561
-rw-r--r--db/schema_migrations/202102161355041
-rw-r--r--db/structure.sql8
5 files changed, 76 insertions, 1 deletions
diff --git a/db/migrate/20210120180956_extend_index_on_ci_builds_metadata.rb b/db/migrate/20210120180956_extend_index_on_ci_builds_metadata.rb
new file mode 100644
index 00000000000..421a2fac1ae
--- /dev/null
+++ b/db/migrate/20210120180956_extend_index_on_ci_builds_metadata.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+class ExtendIndexOnCiBuildsMetadata < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ OLD_INDEX = :index_ci_builds_metadata_on_build_id_and_interruptible
+ NEW_INDEX = :index_ci_builds_metadata_on_build_id_and_id_and_interruptible
+
+ TABLE = :ci_builds_metadata
+
+ def up
+ create_covering_index(TABLE, NEW_INDEX)
+
+ remove_concurrent_index_by_name TABLE, OLD_INDEX
+ end
+
+ def down
+ add_concurrent_index TABLE, :build_id, where: 'interruptible = true', name: OLD_INDEX
+
+ remove_concurrent_index_by_name TABLE, NEW_INDEX
+ end
+
+ private
+
+ def create_covering_index(table, name)
+ return if index_exists_by_name?(table, name)
+
+ disable_statement_timeout do
+ execute <<~SQL
+ CREATE INDEX CONCURRENTLY #{name}
+ ON #{table} (build_id) INCLUDE (id)
+ WHERE interruptible = true
+ SQL
+ end
+ end
+end
diff --git a/db/migrate/20210216135504_add_created_by_to_cluster_agent.rb b/db/migrate/20210216135504_add_created_by_to_cluster_agent.rb
new file mode 100644
index 00000000000..fd679a1c525
--- /dev/null
+++ b/db/migrate/20210216135504_add_created_by_to_cluster_agent.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+class AddCreatedByToClusterAgent < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_cluster_agents_on_created_by_user_id'
+
+ disable_ddl_transaction!
+
+ def up
+ unless column_exists?(:cluster_agents, :created_by_user_id)
+ with_lock_retries do
+ add_column :cluster_agents, :created_by_user_id, :bigint
+ end
+ end
+
+ add_concurrent_index :cluster_agents, :created_by_user_id, name: INDEX_NAME
+ add_concurrent_foreign_key :cluster_agents, :users, column: :created_by_user_id, on_delete: :nullify
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :cluster_agents, :created_by_user_id
+ end
+ end
+end
diff --git a/db/schema_migrations/20210120180956 b/db/schema_migrations/20210120180956
new file mode 100644
index 00000000000..395c9c09df9
--- /dev/null
+++ b/db/schema_migrations/20210120180956
@@ -0,0 +1 @@
+897815c347f04093da5eba420e95b6310454bd493412914e60a296bd710ebde1 \ No newline at end of file
diff --git a/db/schema_migrations/20210216135504 b/db/schema_migrations/20210216135504
new file mode 100644
index 00000000000..99cda90b2ee
--- /dev/null
+++ b/db/schema_migrations/20210216135504
@@ -0,0 +1 @@
+8c676b4142db828b1d2d5dc6bd891eb929d12ab13e9073693ab7d830bcea599a \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index 429f233c8d5..e8d94c87b7c 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -11043,6 +11043,7 @@ CREATE TABLE cluster_agents (
updated_at timestamp with time zone NOT NULL,
project_id bigint NOT NULL,
name text NOT NULL,
+ created_by_user_id bigint,
CONSTRAINT check_3498369510 CHECK ((char_length(name) <= 255))
);
@@ -21622,7 +21623,7 @@ CREATE UNIQUE INDEX index_ci_builds_metadata_on_build_id ON ci_builds_metadata U
CREATE INDEX index_ci_builds_metadata_on_build_id_and_has_exposed_artifacts ON ci_builds_metadata USING btree (build_id) WHERE (has_exposed_artifacts IS TRUE);
-CREATE INDEX index_ci_builds_metadata_on_build_id_and_interruptible ON ci_builds_metadata USING btree (build_id) WHERE (interruptible = true);
+CREATE INDEX index_ci_builds_metadata_on_build_id_and_id_and_interruptible ON ci_builds_metadata USING btree (build_id) INCLUDE (id) WHERE (interruptible = true);
CREATE INDEX index_ci_builds_metadata_on_project_id ON ci_builds_metadata USING btree (project_id);
@@ -21848,6 +21849,8 @@ CREATE INDEX index_cluster_agent_tokens_on_created_by_user_id ON cluster_agent_t
CREATE UNIQUE INDEX index_cluster_agent_tokens_on_token_encrypted ON cluster_agent_tokens USING btree (token_encrypted);
+CREATE INDEX index_cluster_agents_on_created_by_user_id ON cluster_agents USING btree (created_by_user_id);
+
CREATE UNIQUE INDEX index_cluster_agents_on_project_id_and_name ON cluster_agents USING btree (project_id, name);
CREATE UNIQUE INDEX index_cluster_groups_on_cluster_id_and_group_id ON cluster_groups USING btree (cluster_id, group_id);
@@ -24777,6 +24780,9 @@ ALTER TABLE ONLY design_management_designs_versions
ALTER TABLE ONLY analytics_devops_adoption_segments
ADD CONSTRAINT fk_f5aa768998 FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
+ALTER TABLE ONLY cluster_agents
+ ADD CONSTRAINT fk_f7d43dee13 FOREIGN KEY (created_by_user_id) REFERENCES users(id) ON DELETE SET NULL;
+
ALTER TABLE ONLY protected_tag_create_access_levels
ADD CONSTRAINT fk_f7dfda8c51 FOREIGN KEY (protected_tag_id) REFERENCES protected_tags(id) ON DELETE CASCADE;