summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-04 21:07:26 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-04 21:07:26 +0000
commit2242221252d13fdf322b5e59f971a689831c541b (patch)
tree23e30706b58811d2dd2522853cb3bbc27bab028d /db
parent9c66c38ab6ce56cfe06eca21f717977f1684f08c (diff)
downloadgitlab-ce-2242221252d13fdf322b5e59f971a689831c541b.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20221219135535_add_user_defaults_to_private_profile_to_application_settings.rb7
-rw-r--r--db/post_migrate/20221220131020_bump_default_partition_id_value_for_ci_tables.rb56
-rw-r--r--db/schema_migrations/202212191355351
-rw-r--r--db/schema_migrations/202212201310201
-rw-r--r--db/structure.sql1
5 files changed, 66 insertions, 0 deletions
diff --git a/db/migrate/20221219135535_add_user_defaults_to_private_profile_to_application_settings.rb b/db/migrate/20221219135535_add_user_defaults_to_private_profile_to_application_settings.rb
new file mode 100644
index 00000000000..2770456c46f
--- /dev/null
+++ b/db/migrate/20221219135535_add_user_defaults_to_private_profile_to_application_settings.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddUserDefaultsToPrivateProfileToApplicationSettings < Gitlab::Database::Migration[2.1]
+ def change
+ add_column(:application_settings, :user_defaults_to_private_profile, :boolean, default: false, null: false)
+ end
+end
diff --git a/db/post_migrate/20221220131020_bump_default_partition_id_value_for_ci_tables.rb b/db/post_migrate/20221220131020_bump_default_partition_id_value_for_ci_tables.rb
new file mode 100644
index 00000000000..3d06f02a6d6
--- /dev/null
+++ b/db/post_migrate/20221220131020_bump_default_partition_id_value_for_ci_tables.rb
@@ -0,0 +1,56 @@
+# frozen_string_literal: true
+
+class BumpDefaultPartitionIdValueForCiTables < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ TABLES = {
+ ci_build_needs: [:partition_id],
+ ci_build_pending_states: [:partition_id],
+ ci_build_report_results: [:partition_id],
+ ci_build_trace_chunks: [:partition_id],
+ ci_build_trace_metadata: [:partition_id],
+ ci_builds: [:partition_id],
+ ci_builds_runner_session: [:partition_id],
+ ci_job_artifacts: [:partition_id],
+ ci_job_variables: [:partition_id],
+ ci_pending_builds: [:partition_id],
+ ci_pipeline_variables: [:partition_id],
+ ci_pipelines: [:partition_id],
+ ci_running_builds: [:partition_id],
+ ci_sources_pipelines: [:partition_id, :source_partition_id],
+ ci_stages: [:partition_id],
+ ci_unit_test_failures: [:partition_id],
+ p_ci_builds_metadata: [:partition_id]
+ }
+
+ def up
+ change_partitions_default_value(from: 100, to: 101)
+ end
+
+ def down
+ change_partitions_default_value(from: 101, to: 100)
+ end
+
+ private
+
+ def change_partitions_default_value(from:, to:)
+ return unless Gitlab.com?
+
+ TABLES.each do |table_name, columns|
+ next if columns.all? { |column_name| default_value_for(table_name, column_name) == to }
+
+ with_lock_retries do
+ columns.each do |column_name| # rubocop:disable Migration/WithLockRetriesDisallowedMethod
+ change_column_default(table_name, column_name, from: from, to: to)
+ end
+ end
+ end
+ end
+
+ def default_value_for(table_name, column_name)
+ connection
+ .columns(table_name)
+ .find { |column| column.name == column_name.to_s }
+ .default&.to_i
+ end
+end
diff --git a/db/schema_migrations/20221219135535 b/db/schema_migrations/20221219135535
new file mode 100644
index 00000000000..8d46309bc59
--- /dev/null
+++ b/db/schema_migrations/20221219135535
@@ -0,0 +1 @@
+7e9b0184762992556f6c97353f76a45851476ba30667e8afc4946c2aed6d762d \ No newline at end of file
diff --git a/db/schema_migrations/20221220131020 b/db/schema_migrations/20221220131020
new file mode 100644
index 00000000000..36c041b1a33
--- /dev/null
+++ b/db/schema_migrations/20221220131020
@@ -0,0 +1 @@
+8adf517eb859b5c945f70fbdeb911d398cf0a25c75b39b5991280390b70d1adf \ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index a9148140fdd..baa9c6c75e8 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -11574,6 +11574,7 @@ CREATE TABLE application_settings (
max_terraform_state_size_bytes integer DEFAULT 0 NOT NULL,
bulk_import_enabled boolean DEFAULT false NOT NULL,
allow_runner_registration_token boolean DEFAULT true NOT NULL,
+ user_defaults_to_private_profile boolean DEFAULT false NOT NULL,
CONSTRAINT app_settings_container_reg_cleanup_tags_max_list_size_positive CHECK ((container_registry_cleanup_tags_service_max_list_size >= 0)),
CONSTRAINT app_settings_container_registry_pre_import_tags_rate_positive CHECK ((container_registry_pre_import_tags_rate >= (0)::numeric)),
CONSTRAINT app_settings_dep_proxy_ttl_policies_worker_capacity_positive CHECK ((dependency_proxy_ttl_group_policy_worker_capacity >= 0)),