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>2023-01-26 21:07:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-26 21:07:51 +0300
commitcea01cb81787f0d2c119b287a5833f2e267324bc (patch)
treeca37d57c1ec57ef2fa475e6489c4c107cce89dbc /db
parentee24c7d68f57a67754a5d1e2ea99f688029d14bd (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20230119123908_add_temporary_size_index_to_package_files.rb19
-rw-r--r--db/post_migrate/20230119123937_queue_fix_incoherent_packages_size_on_project_statistics.rb29
-rw-r--r--db/schema_migrations/202301191239081
-rw-r--r--db/schema_migrations/202301191239371
-rw-r--r--db/structure.sql2
5 files changed, 52 insertions, 0 deletions
diff --git a/db/post_migrate/20230119123908_add_temporary_size_index_to_package_files.rb b/db/post_migrate/20230119123908_add_temporary_size_index_to_package_files.rb
new file mode 100644
index 00000000000..dbd1f2ce112
--- /dev/null
+++ b/db/post_migrate/20230119123908_add_temporary_size_index_to_package_files.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddTemporarySizeIndexToPackageFiles < Gitlab::Database::Migration[2.1]
+ INDEX_NAME = 'tmp_idx_package_files_on_non_zero_size'
+
+ disable_ddl_transaction!
+
+ def up
+ # Temporary index to be removed in 16.0 https://gitlab.com/gitlab-org/gitlab/-/issues/386695
+ add_concurrent_index :packages_package_files,
+ %i[package_id size],
+ where: 'size IS NOT NULL',
+ name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :packages_package_files, INDEX_NAME
+ end
+end
diff --git a/db/post_migrate/20230119123937_queue_fix_incoherent_packages_size_on_project_statistics.rb b/db/post_migrate/20230119123937_queue_fix_incoherent_packages_size_on_project_statistics.rb
new file mode 100644
index 00000000000..b00888e28d5
--- /dev/null
+++ b/db/post_migrate/20230119123937_queue_fix_incoherent_packages_size_on_project_statistics.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class QueueFixIncoherentPackagesSizeOnProjectStatistics < Gitlab::Database::Migration[2.1]
+ MIGRATION = 'FixIncoherentPackagesSizeOnProjectStatistics'
+ DELAY_INTERVAL = 2.minutes
+ BATCH_SIZE = 17000
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ class Package < MigrationRecord
+ self.table_name = 'packages_packages'
+ end
+
+ def up
+ return unless ::QueueFixIncoherentPackagesSizeOnProjectStatistics::Package.exists?
+
+ queue_batched_background_migration(
+ MIGRATION,
+ :project_statistics,
+ :id,
+ job_interval: DELAY_INTERVAL,
+ batch_size: BATCH_SIZE
+ )
+ end
+
+ def down
+ delete_batched_background_migration(MIGRATION, :project_statistics, :id, [])
+ end
+end
diff --git a/db/schema_migrations/20230119123908 b/db/schema_migrations/20230119123908
new file mode 100644
index 00000000000..9a403a9da30
--- /dev/null
+++ b/db/schema_migrations/20230119123908
@@ -0,0 +1 @@
+9ad4c4a096bdbb8180326618ad686bedee57a53ada952dbfb820855a1f8098a9 \ No newline at end of file
diff --git a/db/schema_migrations/20230119123937 b/db/schema_migrations/20230119123937
new file mode 100644
index 00000000000..53e0789b79e
--- /dev/null
+++ b/db/schema_migrations/20230119123937
@@ -0,0 +1 @@
+2240a3ac34b434da6cf7e814033ff1e318da12bd0b81920764500fe6f80d5416 \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index 513f946eb83..9c16aa0dad2 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -31913,6 +31913,8 @@ CREATE INDEX tmp_idx_for_feedback_comment_processing ON vulnerability_feedback U
CREATE INDEX tmp_idx_for_vulnerability_feedback_migration ON vulnerability_feedback USING btree (id) WHERE ((migrated_to_state_transition = false) AND (feedback_type = 0));
+CREATE INDEX tmp_idx_package_files_on_non_zero_size ON packages_package_files USING btree (package_id, size) WHERE (size IS NOT NULL);
+
CREATE INDEX tmp_index_ci_job_artifacts_on_expire_at_where_locked_unknown ON ci_job_artifacts USING btree (expire_at, job_id) WHERE ((locked = 2) AND (expire_at IS NOT NULL));
CREATE INDEX tmp_index_ci_job_artifacts_on_id_expire_at_file_type_trace ON ci_job_artifacts USING btree (id) WHERE (((date_part('day'::text, timezone('UTC'::text, expire_at)) = ANY (ARRAY[(21)::double precision, (22)::double precision, (23)::double precision])) AND (date_part('minute'::text, timezone('UTC'::text, expire_at)) = ANY (ARRAY[(0)::double precision, (30)::double precision, (45)::double precision])) AND (date_part('second'::text, timezone('UTC'::text, expire_at)) = (0)::double precision)) OR (file_type = 3));